i_img **results = NULL;
int result_alloc = 0;
int channels;
+ int image_colors = 0;
+ i_color black; /* used to expand the palette if needed */
+
+ for (i = 0; i < MAXCHANNELS; ++i)
+ black.channel[i] = 0;
*count = 0;
i_addcolors(img, &col, 1);
}
+ image_colors = ColorMapSize;
++*count;
if (*count > result_alloc) {
if (result_alloc == 0) {
i_tags_addn(&img->tags, "gif_interlace", 0, GifFile->Image.Interlace);
i_tags_addn(&img->tags, "gif_screen_width", 0, GifFile->SWidth);
i_tags_addn(&img->tags, "gif_screen_height", 0, GifFile->SHeight);
+ i_tags_addn(&img->tags, "gif_colormap_size", 0, ColorMapSize);
if (GifFile->SColorMap && !GifFile->Image.ColorMap) {
i_tags_addn(&img->tags, "gif_background", 0,
GifFile->SBackGroundColor);
myfree(GifRow);
return NULL;
}
-
+
+ /* range check the scanline if needed */
+ if (image_colors != 256) {
+ int x;
+ for (x = 0; x < Width; ++x) {
+ while (GifRow[x] >= image_colors) {
+ /* expand the palette since a palette index is too big */
+ i_addcolors(img, &black, 1);
+ ++image_colors;
+ }
+ }
+ }
+
i_ppal(img, 0, Width, j, GifRow);
}
}
return NULL;
}
+ /* range check the scanline if needed */
+ if (image_colors != 256) {
+ int x;
+ for (x = 0; x < Width; ++x) {
+ while (GifRow[x] >= image_colors) {
+ /* expand the palette since a palette index is too big */
+ i_addcolors(img, &black, 1);
+ ++image_colors;
+ }
+ }
+ }
+
i_ppal(img, 0, Width, i, GifRow);
}
}