diff options
| author | Paul Eggert | 2011-08-24 14:20:36 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-08-24 14:20:36 -0700 |
| commit | 011ba6eaacfa50cc9871d0cfea34e8f0a7a5bc43 (patch) | |
| tree | ced7a98ff1eb289559da6ebfda46a8e436640da6 /src/image.c | |
| parent | fe4496a6e27ac892283b8568adbd12831868cc54 (diff) | |
| parent | f22f4808a08e8f985d5e6175bbd13d5260e1ab1a (diff) | |
| download | emacs-011ba6eaacfa50cc9871d0cfea34e8f0a7a5bc43.tar.gz emacs-011ba6eaacfa50cc9871d0cfea34e8f0a7a5bc43.zip | |
Merge from trunk.
Diffstat (limited to 'src/image.c')
| -rw-r--r-- | src/image.c | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/src/image.c b/src/image.c index d10fdad1c54..d0d28bea582 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -7147,7 +7147,6 @@ gif_load (struct frame *f, struct image *img) | |||
| 7147 | ColorMapObject *gif_color_map; | 7147 | ColorMapObject *gif_color_map; |
| 7148 | unsigned long pixel_colors[256]; | 7148 | unsigned long pixel_colors[256]; |
| 7149 | GifFileType *gif; | 7149 | GifFileType *gif; |
| 7150 | int image_height, image_width; | ||
| 7151 | gif_memory_source memsrc; | 7150 | gif_memory_source memsrc; |
| 7152 | Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); | 7151 | Lisp_Object specified_bg = image_spec_value (img->spec, QCbackground, NULL); |
| 7153 | Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL); | 7152 | Lisp_Object specified_file = image_spec_value (img->spec, QCfile, NULL); |
| @@ -7224,19 +7223,13 @@ gif_load (struct frame *f, struct image *img) | |||
| 7224 | } | 7223 | } |
| 7225 | } | 7224 | } |
| 7226 | 7225 | ||
| 7227 | img->corners[TOP_CORNER] = gif->SavedImages[idx].ImageDesc.Top; | 7226 | width = img->width = gif->SWidth; |
| 7228 | img->corners[LEFT_CORNER] = gif->SavedImages[idx].ImageDesc.Left; | 7227 | height = img->height = gif->SHeight; |
| 7229 | image_height = gif->SavedImages[idx].ImageDesc.Height; | ||
| 7230 | img->corners[BOT_CORNER] = img->corners[TOP_CORNER] + image_height; | ||
| 7231 | image_width = gif->SavedImages[idx].ImageDesc.Width; | ||
| 7232 | img->corners[RIGHT_CORNER] = img->corners[LEFT_CORNER] + image_width; | ||
| 7233 | 7228 | ||
| 7234 | width = img->width = max (gif->SWidth, | 7229 | img->corners[TOP_CORNER] = gif->SavedImages[0].ImageDesc.Top; |
| 7235 | max (gif->Image.Left + gif->Image.Width, | 7230 | img->corners[LEFT_CORNER] = gif->SavedImages[0].ImageDesc.Left; |
| 7236 | img->corners[RIGHT_CORNER])); | 7231 | img->corners[BOT_CORNER] = img->corners[TOP_CORNER] + height; |
| 7237 | height = img->height = max (gif->SHeight, | 7232 | img->corners[RIGHT_CORNER] = img->corners[LEFT_CORNER] + width; |
| 7238 | max (gif->Image.Top + gif->Image.Height, | ||
| 7239 | img->corners[BOT_CORNER])); | ||
| 7240 | 7233 | ||
| 7241 | if (!check_image_size (f, width, height)) | 7234 | if (!check_image_size (f, width, height)) |
| 7242 | { | 7235 | { |
| @@ -7291,6 +7284,10 @@ gif_load (struct frame *f, struct image *img) | |||
| 7291 | unsigned char *raster = (unsigned char *) subimage->RasterBits; | 7284 | unsigned char *raster = (unsigned char *) subimage->RasterBits; |
| 7292 | int transparency_color_index = -1; | 7285 | int transparency_color_index = -1; |
| 7293 | int disposal = 0; | 7286 | int disposal = 0; |
| 7287 | int subimg_width = subimage->ImageDesc.Width; | ||
| 7288 | int subimg_height = subimage->ImageDesc.Height; | ||
| 7289 | int subimg_top = subimage->ImageDesc.Top; | ||
| 7290 | int subimg_left = subimage->ImageDesc.Left; | ||
| 7294 | 7291 | ||
| 7295 | /* Find the Graphic Control Extension block for this sub-image. | 7292 | /* Find the Graphic Control Extension block for this sub-image. |
| 7296 | Extract the disposal method and transparency color. */ | 7293 | Extract the disposal method and transparency color. */ |
| @@ -7314,6 +7311,13 @@ gif_load (struct frame *f, struct image *img) | |||
| 7314 | if (j == 0) | 7311 | if (j == 0) |
| 7315 | disposal = 2; | 7312 | disposal = 2; |
| 7316 | 7313 | ||
| 7314 | /* For disposal == 0, the spec says "No disposal specified. The | ||
| 7315 | decoder is not required to take any action." In practice, it | ||
| 7316 | seems we need to treat this like "keep in place", see e.g. | ||
| 7317 | http://upload.wikimedia.org/wikipedia/commons/3/37/Clock.gif */ | ||
| 7318 | if (disposal == 0) | ||
| 7319 | disposal = 1; | ||
| 7320 | |||
| 7317 | /* Allocate subimage colors. */ | 7321 | /* Allocate subimage colors. */ |
| 7318 | memset (pixel_colors, 0, sizeof pixel_colors); | 7322 | memset (pixel_colors, 0, sizeof pixel_colors); |
| 7319 | gif_color_map = subimage->ImageDesc.ColorMap; | 7323 | gif_color_map = subimage->ImageDesc.ColorMap; |
| @@ -7341,34 +7345,34 @@ gif_load (struct frame *f, struct image *img) | |||
| 7341 | int row, pass; | 7345 | int row, pass; |
| 7342 | 7346 | ||
| 7343 | for (y = 0, row = interlace_start[0], pass = 0; | 7347 | for (y = 0, row = interlace_start[0], pass = 0; |
| 7344 | y < image_height; | 7348 | y < subimg_height; |
| 7345 | y++, row += interlace_increment[pass]) | 7349 | y++, row += interlace_increment[pass]) |
| 7346 | { | 7350 | { |
| 7347 | if (row >= image_height) | 7351 | if (row >= subimg_height) |
| 7348 | { | 7352 | { |
| 7349 | row = interlace_start[++pass]; | 7353 | row = interlace_start[++pass]; |
| 7350 | while (row >= image_height) | 7354 | while (row >= subimg_height) |
| 7351 | row = interlace_start[++pass]; | 7355 | row = interlace_start[++pass]; |
| 7352 | } | 7356 | } |
| 7353 | 7357 | ||
| 7354 | for (x = 0; x < image_width; x++) | 7358 | for (x = 0; x < subimg_width; x++) |
| 7355 | { | 7359 | { |
| 7356 | int c = raster[y * image_width + x]; | 7360 | int c = raster[y * subimg_width + x]; |
| 7357 | if (transparency_color_index != c || disposal != 1) | 7361 | if (transparency_color_index != c || disposal != 1) |
| 7358 | XPutPixel (ximg, x + img->corners[LEFT_CORNER], | 7362 | XPutPixel (ximg, x + subimg_left, row + subimg_top, |
| 7359 | row + img->corners[TOP_CORNER], pixel_colors[c]); | 7363 | pixel_colors[c]); |
| 7360 | } | 7364 | } |
| 7361 | } | 7365 | } |
| 7362 | } | 7366 | } |
| 7363 | else | 7367 | else |
| 7364 | { | 7368 | { |
| 7365 | for (y = 0; y < image_height; ++y) | 7369 | for (y = 0; y < subimg_height; ++y) |
| 7366 | for (x = 0; x < image_width; ++x) | 7370 | for (x = 0; x < subimg_width; ++x) |
| 7367 | { | 7371 | { |
| 7368 | int c = raster[y * image_width + x]; | 7372 | int c = raster[y * subimg_width + x]; |
| 7369 | if (transparency_color_index != c || disposal != 1) | 7373 | if (transparency_color_index != c || disposal != 1) |
| 7370 | XPutPixel (ximg, x + img->corners[LEFT_CORNER], | 7374 | XPutPixel (ximg, x + subimg_left, y + subimg_top, |
| 7371 | y + img->corners[TOP_CORNER], pixel_colors[c]); | 7375 | pixel_colors[c]); |
| 7372 | } | 7376 | } |
| 7373 | } | 7377 | } |
| 7374 | } | 7378 | } |