 plug-ins/common/file-gif-load.c |   89 ++++++++++++++++++++-------------------
 1 file changed, 45 insertions(+), 44 deletions(-)

diff --git a/plug-ins/common/file-gif-load.c b/plug-ins/common/file-gif-load.c
index 4fdbe7a..47783cb 100644
--- a/plug-ins/common/file-gif-load.c
+++ b/plug-ins/common/file-gif-load.c
@@ -175,6 +175,50 @@ query (void)
   gimp_register_thumbnail_loader (LOAD_PROC, LOAD_THUMB_PROC);
 }
 
+
+#define MAXCOLORMAPSIZE  256
+
+#define CM_RED           0
+#define CM_GREEN         1
+#define CM_BLUE          2
+
+#define MAX_LZW_BITS     12
+
+#define INTERLACE          0x40
+#define LOCALCOLORMAP      0x80
+#define BitSet(byte, bit)  (((byte) & (bit)) == (bit))
+
+#define ReadOK(file,buffer,len) (fread(buffer, len, 1, file) != 0)
+#define LM_to_uint(a,b)         (((b)<<8)|(a))
+
+#define GRAYSCALE        1
+#define COLOR            2
+
+typedef guchar CMap[3][MAXCOLORMAPSIZE];
+
+static struct
+{
+  guint Width;
+  guint Height;
+  CMap  ColorMap;
+  guint BitPixel;
+  guint ColorResolution;
+  guint Background;
+  guint AspectRatio;
+  /*
+   **
+   */
+  gint  GrayScale;
+} GifScreen;
+
+static struct
+{
+  gint transparent;
+  gint delayTime;
+  gint inputFlag;
+  gint disposal;
+} Gif89 = { -1, -1, -1, 0 };
+
 static void
 run (const gchar      *name,
      gint              nparams,
@@ -227,7 +271,7 @@ run (const gchar      *name,
 #endif
           if (! promote_to_rgb)
             gimp_image_set_colormap (image_ID,
-                                     gimp_cmap, highest_used_index + 1);
+                                     gimp_cmap, GifScreen.BitPixel);
 
           *nreturn_vals = 2;
           values[1].type         = GIMP_PDB_IMAGE;
@@ -259,49 +303,6 @@ run (const gchar      *name,
 }
 
 
-#define MAXCOLORMAPSIZE  256
-
-#define CM_RED           0
-#define CM_GREEN         1
-#define CM_BLUE          2
-
-#define MAX_LZW_BITS     12
-
-#define INTERLACE          0x40
-#define LOCALCOLORMAP      0x80
-#define BitSet(byte, bit)  (((byte) & (bit)) == (bit))
-
-#define ReadOK(file,buffer,len) (fread(buffer, len, 1, file) != 0)
-#define LM_to_uint(a,b)         (((b)<<8)|(a))
-
-#define GRAYSCALE        1
-#define COLOR            2
-
-typedef guchar CMap[3][MAXCOLORMAPSIZE];
-
-static struct
-{
-  guint Width;
-  guint Height;
-  CMap  ColorMap;
-  guint BitPixel;
-  guint ColorResolution;
-  guint Background;
-  guint AspectRatio;
-  /*
-   **
-   */
-  gint  GrayScale;
-} GifScreen;
-
-static struct
-{
-  gint transparent;
-  gint delayTime;
-  gint inputFlag;
-  gint disposal;
-} Gif89 = { -1, -1, -1, 0 };
-
 static gboolean ReadColorMap (FILE        *fd,
                               gint         number,
                               CMap         buffer,
