Opened 20 months ago
Closed 20 months ago
#125 closed defect (fixed)
bug in GIF saving. 8x8 pixels, solid color 0 to 3
Reported by: | 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)
Change History (13)
comment:1 Changed 20 months ago by
Owner: | changed from pulkomandy to Thomas Bernard |
---|---|
Status: | new → accepted |
comment:2 Changed 20 months ago by
Milestone: | → 2.7 |
---|---|
Priority: | major → minor |
Type: | enhancement → defect |
comment:3 Changed 20 months ago by
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 20 months ago by
Attachment: | gfx2_gif_error_pic_.GIF added |
---|
comment:4 Changed 20 months ago by
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 follow-up: 6 Changed 20 months ago by
please answer my question : how the GIF file was produced ??? (which tool)
comment:6 Changed 20 months ago by
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:8 Changed 20 months ago by
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 :
- the "bits per codes" (nb_bits) should be incremented just after the last code encoding the last pixel (just before the EOF code)
- there are exactly the right number of free bits remaining in the byte data stream...
comment:9 Changed 20 months ago by
there is a comment about the corner case in the code :)
https://gitlab.com/GrafX2/grafX2/blob/master/src/fileformats.c#L5313
I had translated the comment at the time :
https://gitlab.com/GrafX2/grafX2/commit/8691554a263cd34b88a1b01a5caec9a25120fc8d
comment:10 Changed 20 months ago by
Keywords: | gif added |
---|---|
Status: | accepted → assigned |
Summary: | red flash when gif is selected in save/load dialog → bug in GIF saving. 8x8 pixels, solid color 0 to 3 |
comment:12 Changed 20 months ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
please attach the file.
how the GIF file was produced ???
are there some messages displayed when running GrafX2 with the "-v" option ?