jiayouxjh / grafx2

Automatically exported from code.google.com/p/grafx2
0 stars 0 forks source link

Palette is broken when loading certain GIF files ("Local color table") #360

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Load each of the two attached GIF files.
They should look identical. However, the first one appears to have a totally 
messed up palette when loaded in Grafx2. Gimp, GThumb,Firefox, etc display them 
both correctly.

The second image was created by loading the first in gimp and saving it out 
again.

Looking at the output of a diff of 'strings' command output between the files, 
I suspect the first file has an 'application extension' block associated with 
NETSCAPE, whereas the second (GIMP-generated) one does not.

Original issue reported on code.google.com by 00a...@gmail.com on 22 Jun 2010 at 4:16

Attachments:

GoogleCodeExporter commented 9 years ago
It seems the files were converted to png format when you attached them.

Original comment by yrizoud on 22 Jun 2010 at 7:50

GoogleCodeExporter commented 9 years ago
Ok, here is a zipfile -- hopefully it won't try to autoconvert the images 
inside that!

Original comment by 00a...@gmail.com on 22 Jun 2010 at 8:37

Attachments:

GoogleCodeExporter commented 9 years ago
Indeed this image shows the problem.
A look at the source code shows two bugs in the old GIF loading code:

1) It seems Grafx2 believes an image has sorted palette when the image is 
interlaced (IDB.Indicator & 0x40  -- it seems it should be 0x20)

2) The code for sorted palette seems to think the palette will be all R 
components, then all G, then all B. Actually the spec says this indicator only 
informs the viewing program that the colors are in order of decreasing usage: 
color #0 is more used than #1, which is more used than #2 etc. This is coded at 
two places: for "IDB.Indicator & 0x40" and "LSDB.Aspect & 0x80"

So, this image must be one of two cases:
- It has no local palette but its global palette is sorted
- It has a local palette and is an interlaced GIF.

Original comment by yrizoud on 22 Jun 2010 at 9:30

GoogleCodeExporter commented 9 years ago
Fixed in r1520.
For the record, both images are transparent 16-color GIFs. In the second, the 
palette is global, declared in the Logical Screen Descriptor Block.
In the first, there is no global palette, it's a local palette declared in the 
Image Descriptor Block. According to the standards, both methods are equally 
valid, and since it's not a animation it should make no difference. The bugs 
were in Grafx2 since the beginning of times, so it seems 99% of GIFs in the 
wild have no local palette.

Original comment by yrizoud on 22 Jun 2010 at 9:45