diff libinterp/dldfcn/__magick_read__.cc @ 19728:c334e4af3a1b

Fix incorrect writing of grayscale JPEG images (bugs #41673, #44118, #42474) * __magick_read__.cc: when writing grayscale images, we should create a Magick::Image object of Magick::GrayscaleType type, then use Magick::Color with only the red channel set (the other channels would be ignored). However, this seems to not work for JPEG images which would then generate grayscale images with one third of the intensity. This fixes it.
author Ilya Kurdyukov <olme8@mail.ru>
date Wed, 11 Feb 2015 17:40:04 +0000
parents 914c3ce73665
children c4728e4105b8
line wrap: on
line diff
--- a/libinterp/dldfcn/__magick_read__.cc	Tue Feb 10 23:19:44 2015 +0100
+++ b/libinterp/dldfcn/__magick_read__.cc	Wed Feb 11 17:40:04 2015 +0000
@@ -1108,8 +1108,9 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    Magick::Color c;
-                    c.redQuantum (double (*img_fvec) / divisor);
+                    const double grey = double (*img_fvec) / divisor;
+                    Magick::Color c (grey, grey, grey);
+                    pix[GM_idx] = c;
                     pix[GM_idx] = c;
                     img_fvec++;
                     GM_idx += nCols;