From: Paul Eggert Date: Wed, 21 May 2014 19:51:58 +0000 (-0700) Subject: Don't assume that ImageMagick uses a 16-bit quantum. X-Git-Tag: emacs-25.0.90~2640^2~74 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6c596cb2ea3075afab8812f45803683be2949323;p=emacs.git Don't assume that ImageMagick uses a 16-bit quantum. * 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 --- diff --git a/src/ChangeLog b/src/ChangeLog index d6e21a777c2..29039395374 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2014-05-21 Paul Eggert + + 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 * fns.c (Fnreverse): Accept strings for SEQ and update doc-string. diff --git a/src/image.c b/src/image.c index 047f7517501..f7c3ef52563 100644 --- a/src/image.c +++ b/src/image.c @@ -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);