]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't assume that ImageMagick uses a 16-bit quantum.
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 21 May 2014 19:51:58 +0000 (12:51 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 21 May 2014 19:51:58 +0000 (12:51 -0700)
* image.c (imagemagick_load_image): Port to hosts that do not use
a 16-bit quantum, i.e., QuantumRange does not equal 65535.

Fixes: debbugs:17519
src/ChangeLog
src/image.c

index d6e21a777c2b1219086f5a5a5dc9fc9c496bbaa2..2903939537408196156ca5ecbb17872da4cea3b1 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-21  Paul Eggert  <eggert@cs.ucla.edu>
+
+       Don't assume that ImageMagick uses a 16-bit quantum (Bug#17519).
+       * image.c (imagemagick_load_image): Port to hosts that do not use
+       a 16-bit quantum, i.e., QuantumRange does not equal 65535.
+
 2014-05-21  Leo Liu  <sdl.web@gmail.com>
 
        * fns.c (Fnreverse): Accept strings for SEQ and update doc-string.
index 047f7517501f4085c13ddddb6fa5c8bfde9356ea..f7c3ef52563e31c40f1dcb77826e9b3fa643f48e 100644 (file)
@@ -8368,6 +8368,7 @@ imagemagick_load_image (struct frame *f, struct image *img,
 #endif /* HAVE_MAGICKEXPORTIMAGEPIXELS */
     {
       size_t image_height;
+      double color_scale = 65535.0 / QuantumRange;
 
       /* Try to create a x pixmap to hold the imagemagick pixmap.  */
       if (!image_create_x_image_and_pixmap (f, img, width, height, 0,
@@ -8408,9 +8409,9 @@ imagemagick_load_image (struct frame *f, struct image *img,
               PixelGetMagickColor (pixels[x], &pixel);
               XPutPixel (ximg, x, y,
                          lookup_rgb_color (f,
-                                           pixel.red,
-                                           pixel.green,
-                                           pixel.blue));
+                                          color_scale * pixel.red,
+                                          color_scale * pixel.green,
+                                          color_scale * pixel.blue));
             }
         }
       DestroyPixelIterator (iterator);