#125 closed defect (fixed)

bug in GIF saving. 8x8 pixels, solid color 0 to 3

Reported by: HoraK-FDF@… Owned by: Thomas Bernard
Priority: minor Milestone: 2.7
Component: GrafX2 Version: 2.7
Keywords: gif Cc:

Description

Hi,

the grafx2 flashes red when a gif is selected that has only one frame and this frame consist of only one color. It flashes a second time while loading.

I've used grafx2-2.7wip2726-dir_fix

Attachments (1)

gfx2_gif_error_pic_.GIF (861 bytes) - added by HoraK-FDF@… 16 months ago.

Download all attachments as: .zip

Change History (13)

comment:1 Changed 16 months ago by Thomas Bernard

Owner: changed from pulkomandy to Thomas Bernard
Status: newaccepted

please attach the file.

how the GIF file was produced ???

are there some messages displayed when running GrafX2 with the "-v" option ?

comment:2 Changed 16 months ago by Thomas Bernard

Milestone: 2.7
Priority: majorminor
Type: enhancementdefect

comment:3 Changed 16 months ago by HoraK-FDF@…

here I investigated a bit more the picture must be 8x8 (only tested equal x and y values) and the picture must be a solid color from 0-3. When mixing colors from 0-3 the bug doesn't occur.

here is the output with -v:

Change_directory("f:\#dwn\grafx2\GRAFX2~3.7WI\bin")
GIF extension "CRNG"
GIF Graphics Control Extension : transp=0 (color #0) delay=100ms disposal_method
=1
GIF Image descriptor 1 Pos (0,0) 8x8 no local palette(8bpp)
GIF image #0 2bits (0,0) 8x8
Change_directory("f:\#dwn\grafx2\GRAFX2~3.7WI\bin")
GIF extension "CRNG"
GIF Graphics Control Extension : transp=0 (color #0) delay=100ms disposal_method
=1
GIF Image descriptor 1 Pos (0,0) 8x8 no local palette(8bpp)
GIF image #0 2bits (0,0) 8x8
SDL_ACTIVEEVENT gain=0 state=1 (Mouse )
SDL_ACTIVEEVENT gain=0 state=2 (Keyboard )
SDL_ACTIVEEVENT gain=1 state=1 (Mouse )
SDL_ACTIVEEVENT gain=0 state=1 (Mouse )
SDL_ACTIVEEVENT gain=1 state=1 (Mouse )
SDL_ACTIVEEVENT gain=1 state=6 (Keyboard Iconification)
SDL_VIDEOEXPOSE
Change_directory("f:\#dwn\grafx2\GRAFX2~3.7WI\bin")
GIF extension "CRNG"
GIF Graphics Control Extension : transp=0 (color #0) delay=100ms disposal_method
=1
GIF Image descriptor 1 Pos (0,0) 8x8 no local palette(8bpp)
Load_GIF() Invalid code 21 (should be <=16)
Unable to load file NO_NAME.GIF (error 2)! format: gif
Error number 0 occurred in file loadsave.c, line 704, function Load_image.
GIF extension "CRNG"
GIF Graphics Control Extension : transp=0 (color #0) delay=100ms disposal_method
=1
GIF Image descriptor 1 Pos (0,0) 8x8 no local palette(8bpp)
Load_GIF() Invalid code 21 (should be <=16)
Unable to load file NO_NAME.GIF (error 2)! format: gif
Error number 0 occurred in file loadsave.c, line 704, function Load_image.
GIF image #0 2bits (0,0) 8x8

Changed 16 months ago by HoraK-FDF@…

Attachment: gfx2_gif_error_pic_.GIF added

comment:4 Changed 16 months ago by HoraK-FDF@…

to note is also that even if it says unable to load file it loads it properly. As I have seen by using lua scripts for the other issue the bug was also there in v2.5

comment:5 Changed 16 months ago by Thomas Bernard

please answer my question : how the GIF file was produced ??? (which tool)

comment:6 in reply to:  5 Changed 16 months ago by HoraK-FDF@…

Replying to Thomas Bernard:

please answer my question : how the GIF file was produced ??? (which tool)

with: GrafX2
how: start gfx2, set size to 8x8, floodfill with color 0-3 if color 0 no floodfill is need because it is already all color 0 and save.

comment:7 Changed 16 months ago by Thomas Bernard

Thanks. It is then very probably a bug in the saving code.

comment:8 Changed 16 months ago by Thomas Bernard

well this is very complicated to be sure where the problem is.
When compressing 64 pixels images of the same values for 2bits per pixels (the minimum with gif as 1bpp are in fact encoded as 2bpp) the EOF gif code is encoded as 4bits by Save_GIF() and fills exactly the last byte of data.
But Load_GIF() is expecting a 5 bits code. So it needs to read 1 bit more from the GIF and that fails...

I do think the code should be written with 5 bits in this case, but we need to be sure...

thanks for finding this bug, because the probability is very low !
it happens because 2 conditions are met :

  1. the "bits per codes" (nb_bits) should be incremented just after the last code encoding the last pixel (just before the EOF code)
  2. there are exactly the right number of free bits remaining in the byte data stream...

comment:9 Changed 16 months ago by Thomas Bernard

comment:10 Changed 16 months ago by Thomas Bernard

Keywords: gif added
Status: acceptedassigned
Summary: red flash when gif is selected in save/load dialogbug in GIF saving. 8x8 pixels, solid color 0 to 3

comment:12 Changed 16 months ago by Thomas Bernard

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.