GraphicsMagick: ColorizeImage(): Apply clipping and rounding to ...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.14929.1644101246.1940.graphicsmagick-commit@lists.sourceforge.net>
changeset 3207580e44c9 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=3207580e44c9
summary: ColorizeImage(): Apply clipping and rounding to handle out of range values and provide the most accurate

diffstat:

 ChangeLog                              |   6 ++++++
 VisualMagick/installer/inc/version.isx |   4 ++--
 magick/fx.c                            |  16 ++++++++--------
 magick/version.h                       |   4 ++--
 www/Changelog.html                     |   5 +++++
 5 files changed, 23 insertions(+), 12 deletions(-)

diffs (82 lines):

diff -r 523c681ea873 -r 3207580e44c9 ChangeLog
--- a/ChangeLog	Sun Jan 30 13:48:31 2022 -0600
+++ b/ChangeLog	Sat Feb 05 16:47:11 2022 -0600
@@ -1,3 +1,9 @@
+2022-02-05  Bob Friesenhahn  <[email protected]>
+
+        * magick/fx.c (ColorizeImagePixelsCB): Apply clipping and rounding
+        to handle out of range values and provide the most accurate
+        result.  Addresses SourceForge bug #662 "Broken -colorize".
+
 2022-01-30  Bob Friesenhahn  <[email protected]>
 
         * coders/jp2.c (ReadJP2Image): Jasper 3.0.0 hid the functions we
diff -r 523c681ea873 -r 3207580e44c9 VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Sun Jan 30 13:48:31 2022 -0600
+++ b/VisualMagick/installer/inc/version.isx	Sat Feb 05 16:47:11 2022 -0600
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020220130"
-#define public MagickPackageReleaseDate "snapshot-20220130"
+#define public MagickPackageVersionAddendum ".020220205"
+#define public MagickPackageReleaseDate "snapshot-20220205"
diff -r 523c681ea873 -r 3207580e44c9 magick/fx.c
--- a/magick/fx.c	Sun Jan 30 13:48:31 2022 -0600
+++ b/magick/fx.c	Sat Feb 05 16:47:11 2022 -0600
@@ -214,17 +214,17 @@
 
   for (i=0; i < npixels; i++)
     {
-      new_pixels[i].red=(Quantum)
-        ((source_pixels[i].red*(100.0-options.amount.red)+
+      new_pixels[i].red=RoundDoubleToQuantum
+        (((double) source_pixels[i].red*(100.0-options.amount.red)+
           options.color.red*options.amount.red)/100.0);
-      new_pixels[i].green=(Quantum)
-        ((source_pixels[i].green*(100.0-options.amount.green)+
+      new_pixels[i].green=RoundDoubleToQuantum
+        (((double) source_pixels[i].green*(100.0-options.amount.green)+
           options.color.green*options.amount.green)/100.0);
-      new_pixels[i].blue=(Quantum)
-        ((source_pixels[i].blue*(100.0-options.amount.blue)+
+      new_pixels[i].blue=RoundDoubleToQuantum
+        (((double) source_pixels[i].blue*(100.0-options.amount.blue)+
           options.color.blue*options.amount.blue)/100.0);
-      new_pixels[i].opacity=(Quantum)
-        ((source_pixels[i].opacity*(100.0-options.amount.opacity)+
+      new_pixels[i].opacity=RoundDoubleToQuantum
+        (((double) source_pixels[i].opacity*(100.0-options.amount.opacity)+
           options.color.opacity*options.amount.opacity)/100.0);
     }
 
diff -r 523c681ea873 -r 3207580e44c9 magick/version.h
--- a/magick/version.h	Sun Jan 30 13:48:31 2022 -0600
+++ b/magick/version.h	Sat Feb 05 16:47:11 2022 -0600
@@ -38,8 +38,8 @@
 #define MagickLibVersion  0x262300
 #define MagickLibVersionText  "1.4"
 #define MagickLibVersionNumber 26,23,0
-#define MagickChangeDate   "20220130"
-#define MagickReleaseDate  "snapshot-20220130"
+#define MagickChangeDate   "20220205"
+#define MagickReleaseDate  "snapshot-20220205"
 
 /*
   The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
diff -r 523c681ea873 -r 3207580e44c9 www/Changelog.html
--- a/www/Changelog.html	Sun Jan 30 13:48:31 2022 -0600
+++ b/www/Changelog.html	Sat Feb 05 16:47:11 2022 -0600
@@ -35,6 +35,11 @@
 <div class="document">
 
 
+<p>2022-02-05  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+* magick/fx.c (ColorizeImagePixelsCB): Apply clipping and rounding
+to handle out of range values and provide the most accurate
+result.  Addresses SourceForge bug #662 &quot;Broken -colorize&quot;.</blockquote>
 <p>2022-01-30  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 * coders/jp2.c (ReadJP2Image): Jasper 3.0.0 hid the functions we
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.