# HG changeset patch
# User Markus Mützel <markus.muetzel@gmx.de>
# Date 1636652428 -3600
#      Thu Nov 11 18:40:28 2021 +0100
# Node ID c94d1ef87c57ef03d81b73f1dafbe534dab55f99
# Parent  7835150ba1754b89df6a36480ec4c65b78500aa2
__magick_read__.cc: Help compiler selecting the correct constructor (bug #49653).

* libinterp/corefcn/__magick_read__.cc: Cast arguments of Magick::Color
  constructor to Magick::Quantum explicitly.

diff -r 7835150ba175 -r c94d1ef87c57 libinterp/corefcn/__magick_read__.cc
--- a/libinterp/corefcn/__magick_read__.cc	Tue Nov 02 11:00:45 2021 -0400
+++ b/libinterp/corefcn/__magick_read__.cc	Thu Nov 11 18:40:28 2021 +0100
@@ -1205,7 +1205,8 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    const double grey = math::round (double (*img_fvec) / divisor);
+                    const Magick::Quantum grey
+                      = math::round (double (*img_fvec) / divisor);
                     Magick::Color c (grey, grey, grey);
                     pix[GM_idx] = c;
                     img_fvec++;
@@ -1236,7 +1237,8 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    double grey = math::round (double (*img_fvec) / divisor);
+                    const Magick::Quantum grey
+                      = math::round (double (*img_fvec) / divisor);
                     Magick::Color c (grey, grey, grey,
                                      MaxRGB - math::round (double (*a_fvec) / divisor));
                     pix[GM_idx] = c;
@@ -1272,9 +1274,13 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    Magick::Color c (math::round (double (*img_fvec)          / divisor),
-                                     math::round (double (img_fvec[G_offset]) / divisor),
-                                     math::round (double (img_fvec[B_offset]) / divisor));
+                    Magick::Color
+                      c (static_cast<Magick::Quantum>
+                           (math::round (double (*img_fvec)          / divisor)),
+                         static_cast<Magick::Quantum>
+                           (math::round (double (img_fvec[G_offset]) / divisor)),
+                         static_cast<Magick::Quantum>
+                           (math::round (double (img_fvec[B_offset]) / divisor)));
                     pix[GM_idx] = c;
                     img_fvec++;
                     GM_idx += nCols;
@@ -1308,10 +1314,15 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    Magick::Color c (math::round (double (*img_fvec)          / divisor),
-                                     math::round (double (img_fvec[G_offset]) / divisor),
-                                     math::round (double (img_fvec[B_offset]) / divisor),
-                                     MaxRGB - math::round (double (*a_fvec) / divisor));
+                    Magick::Color
+                      c (static_cast<Magick::Quantum>
+                           (math::round (double (*img_fvec)          / divisor)),
+                         static_cast<Magick::Quantum>
+                           (math::round (double (img_fvec[G_offset]) / divisor)),
+                         static_cast<Magick::Quantum>
+                           (math::round (double (img_fvec[B_offset]) / divisor)),
+                         static_cast<Magick::Quantum>
+                           (MaxRGB - math::round (double (*a_fvec) / divisor)));
                     pix[GM_idx] = c;
                     img_fvec++;
                     a_fvec++;
@@ -1347,10 +1358,15 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    Magick::Color c (math::round (double (*img_fvec)          / divisor),
-                                     math::round (double (img_fvec[M_offset]) / divisor),
-                                     math::round (double (img_fvec[Y_offset]) / divisor),
-                                     math::round (double (img_fvec[K_offset]) / divisor));
+                    Magick::Color
+                      c (static_cast<Magick::Quantum>
+                           (math::round (double (*img_fvec)          / divisor)),
+                         static_cast<Magick::Quantum>
+                           (math::round (double (img_fvec[M_offset]) / divisor)),
+                         static_cast<Magick::Quantum>
+                           (math::round (double (img_fvec[Y_offset]) / divisor)),
+                         static_cast<Magick::Quantum>
+                           (math::round (double (img_fvec[K_offset]) / divisor)));
                     pix[GM_idx] = c;
                     img_fvec++;
                     GM_idx += nCols;
@@ -1386,10 +1402,15 @@
               {
                 for (octave_idx_type row = 0; row < nRows; row++)
                   {
-                    Magick::Color c (math::round (double (*img_fvec)          / divisor),
-                                     math::round (double (img_fvec[M_offset]) / divisor),
-                                     math::round (double (img_fvec[Y_offset]) / divisor),
-                                     math::round (double (img_fvec[K_offset]) / divisor));
+                    Magick::Color
+                      c (static_cast<Magick::Quantum>
+                           (math::round (double (*img_fvec)          / divisor)),
+                         static_cast<Magick::Quantum>
+                           (math::round (double (img_fvec[M_offset]) / divisor)),
+                         static_cast<Magick::Quantum>
+                           (math::round (double (img_fvec[Y_offset]) / divisor)),
+                         static_cast<Magick::Quantum>
+                           (math::round (double (img_fvec[K_offset]) / divisor)));
                     pix[GM_idx] = c;
                     ind[GM_idx] = MaxRGB - math::round (double (*a_fvec) / divisor);
                     img_fvec++;
