diff options
author | Marcin Bukat <marcin.bukat@gmail.com> | 2013-04-18 09:36:05 +0200 |
---|---|---|
committer | Marcin Bukat <marcin.bukat@gmail.com> | 2013-04-18 09:42:48 +0200 |
commit | 62cb84a57c6faa84e249e1a62e9e08af824b7ff2 (patch) | |
tree | 6c42e12a1b2201c7bf363ea7b0b9135def3d01f4 /apps | |
parent | 540e5d103f803cfd508297f483c054328c59375f (diff) | |
download | rockbox-62cb84a57c6faa84e249e1a62e9e08af824b7ff2.tar.gz rockbox-62cb84a57c6faa84e249e1a62e9e08af824b7ff2.zip |
imageviewer: fix animated gifs handling
If disposal method is set to BACKGROUND one would expect that
canvas should be restored to global background color. That is
what gif standard suggests. Most (all?) decoders however treat
this as reseting canvas to transparency or fixed, decoder
specific background color. Virtually all gifs are prepared with
this in mind so to not break them we can't follow standard here.
Change-Id: I90ca712bba89d4190771eb5320eabda353d3e2bb
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/imageviewer/gif/gif.c | 7 | ||||
-rw-r--r-- | apps/plugins/imageviewer/gif/gif_decoder.c | 26 |
2 files changed, 10 insertions, 23 deletions
diff --git a/apps/plugins/imageviewer/gif/gif.c b/apps/plugins/imageviewer/gif/gif.c index c3cad71e10..31fd11d9a6 100644 --- a/apps/plugins/imageviewer/gif/gif.c +++ b/apps/plugins/imageviewer/gif/gif.c | |||
@@ -110,10 +110,9 @@ static int load_image(char *filename, struct image_info *info, | |||
110 | 110 | ||
111 | if (!iv->running_slideshow) | 111 | if (!iv->running_slideshow) |
112 | { | 112 | { |
113 | rb->lcd_putsf(0, 2, "image %dx%d", | 113 | rb->lcd_putsf(0, 2, "file: %s", |
114 | p_decoder->width, | 114 | filename); |
115 | p_decoder->height); | 115 | rb->lcd_putsf(0, 3, "size: %dx%d", |
116 | rb->lcd_putsf(0, 3, "decoding %d*%d", | ||
117 | p_decoder->width, | 116 | p_decoder->width, |
118 | p_decoder->height); | 117 | p_decoder->height); |
119 | rb->lcd_update(); | 118 | rb->lcd_update(); |
diff --git a/apps/plugins/imageviewer/gif/gif_decoder.c b/apps/plugins/imageviewer/gif/gif_decoder.c index 74330c3d1d..e45814cbef 100644 --- a/apps/plugins/imageviewer/gif/gif_decoder.c +++ b/apps/plugins/imageviewer/gif/gif_decoder.c | |||
@@ -125,30 +125,18 @@ void gif_open(char *filename, struct gif_decoder *d) | |||
125 | d->frames_count = 0; | 125 | d->frames_count = 0; |
126 | } | 126 | } |
127 | 127 | ||
128 | static void set_canvas_background(GifPixelType *Line, pixel_t *out, | 128 | static void set_canvas_background(pixel_t *out, GifFileType *GifFile) |
129 | GifFileType *GifFile) | ||
130 | { | 129 | { |
131 | int i; | ||
132 | |||
133 | /* Reading Gif spec it seems one should always use background color | 130 | /* Reading Gif spec it seems one should always use background color |
134 | * in canvas but most real files omit this and sets background color to 0 | 131 | * in canvas but most real files omit this and sets background color to 0 |
135 | * (which IS valid index). We can choose to either conform to standard | 132 | * (which IS valid index). We can choose to either conform to standard |
136 | * (and wrongly display most of gifs with transparency) or stick to | 133 | * (and wrongly display most of gifs with transparency) or stick to |
137 | * common practise and treat background color 0 as transparent. | 134 | * common practise and treat background color 0 as transparent. |
138 | * I preffer the second. | 135 | * Moreover when dispose method is BACKGROUND spec suggest |
136 | * to reset canvas to global background color specified in gif BUT | ||
137 | * all renderers I know use transparency instead. | ||
139 | */ | 138 | */ |
140 | if (GifFile->SColorMap && GifFile->SBackGroundColor != 0) | 139 | memset(out, PIXEL_TRANSPARENT, PIXELS_SZ); |
141 | { | ||
142 | memset(Line, GifFile->SBackGroundColor, GifFile->SWidth); | ||
143 | |||
144 | for(i=0; i<GifFile->SHeight; i++) | ||
145 | gif2pixels(Line, out, i, 0, GifFile->SWidth); | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | memset(out, PIXEL_TRANSPARENT, PIXELS_SZ); | ||
150 | } | ||
151 | |||
152 | } | 140 | } |
153 | 141 | ||
154 | /* var names adhere to giflib coding style */ | 142 | /* var names adhere to giflib coding style */ |
@@ -212,7 +200,7 @@ void gif_decode(struct gif_decoder *d, | |||
212 | } | 200 | } |
213 | 201 | ||
214 | /* Global background color */ | 202 | /* Global background color */ |
215 | set_canvas_background(Line, pixels_buffer[0], GifFile); | 203 | set_canvas_background(pixels_buffer[0], GifFile); |
216 | 204 | ||
217 | bm.width = GifFile->SWidth; | 205 | bm.width = GifFile->SWidth; |
218 | bm.height = GifFile->SHeight; | 206 | bm.height = GifFile->SHeight; |
@@ -335,7 +323,7 @@ void gif_decode(struct gif_decoder *d, | |||
335 | switch (GifFile->Image.GCB->DisposalMode) | 323 | switch (GifFile->Image.GCB->DisposalMode) |
336 | { | 324 | { |
337 | case DISPOSE_BACKGROUND: | 325 | case DISPOSE_BACKGROUND: |
338 | set_canvas_background(Line, pixels_buffer[buf_idx], | 326 | set_canvas_background(pixels_buffer[buf_idx], |
339 | GifFile); | 327 | GifFile); |
340 | break; | 328 | break; |
341 | 329 | ||