GraphicsMagick: ResizeImage(): Clarify HorizontalFilter()/Vertic...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.5143.1679254915.1748.graphicsmagick-commit@lists.sourceforge.net>
changeset 5ccb2b5fc061 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=5ccb2b5fc061
summary: ResizeImage(): Clarify HorizontalFilter()/VerticalFilter() loops.

diffstat:

 ChangeLog                              |    5 +
 VisualMagick/installer/inc/version.isx |    4 +-
 magick/resize.c                        |  152 +++++++++++++++++++++-----------
 magick/version.h                       |    4 +-
 www/Changelog.html                     |    7 +
 5 files changed, 117 insertions(+), 55 deletions(-)

diffs (287 lines):

diff -r 60b132017fce -r 5ccb2b5fc061 ChangeLog
--- a/ChangeLog	Sat Mar 18 18:16:06 2023 -0500
+++ b/ChangeLog	Sun Mar 19 14:41:43 2023 -0500
@@ -1,3 +1,8 @@
+2023-03-19  Bob Friesenhahn  <[email protected]>
+
+	* magick/resize.c (ResizeImage): Clarify
+	HorizontalFilter()/VerticalFilter() loops.
+
 2023-03-18  Fojtik Jaroslav  <[email protected]>
 
 	* coders/png.c There were 2 defects that prevented eXIf chunk
diff -r 60b132017fce -r 5ccb2b5fc061 VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Sat Mar 18 18:16:06 2023 -0500
+++ b/VisualMagick/installer/inc/version.isx	Sun Mar 19 14:41:43 2023 -0500
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020230318"
-#define public MagickPackageReleaseDate "snapshot-20230318"
+#define public MagickPackageVersionAddendum ".020230319"
+#define public MagickPackageReleaseDate "snapshot-20230319"
diff -r 60b132017fce -r 5ccb2b5fc061 magick/resize.c
--- a/magick/resize.c	Sat Mar 18 18:16:06 2023 -0500
+++ b/magick/resize.c	Sun Mar 19 14:41:43 2023 -0500
@@ -849,6 +849,9 @@
   MagickBool
     monitor_active;
 
+  const MagickBool
+    matte = ((destination->matte) || (destination->colorspace == CMYKColorspace));
+
   MagickPassFail
     status=MagickPass;
 
@@ -966,27 +969,25 @@
         {
           source_indexes=AccessImmutableIndexes(source);
           indexes=AccessMutableIndexes(destination);
-          for (y=0; y < (long) destination->rows; y++)
+          if (matte)
             {
-              double
-                weight;
-
-              DoublePixelPacket
-                pixel;
-
-              long
-                j;
-
-              register long
-                i;
-
-              pixel=zero;
-              if ((destination->matte) || (destination->colorspace == CMYKColorspace))
+              for (y=0; y < (long) destination->rows; y++)
                 {
                   double
                     transparency_coeff,
-                    normalize;
+                    normalize,
+                    weight;
+
+                  DoublePixelPacket
+                    pixel;
 
+                  long
+                    j;
+
+                  register long
+                    i;
+
+                  pixel=zero;
                   normalize=0.0;
                   for (i=0; i < n; i++)
                     {
@@ -1008,9 +1009,33 @@
                   q[y].green=RoundDoubleToQuantum(pixel.green);
                   q[y].blue=RoundDoubleToQuantum(pixel.blue);
                   q[y].opacity=RoundDoubleToQuantum(pixel.opacity);
+
+                  if ((indexes != (IndexPacket *) NULL) &&
+                      (source_indexes != (IndexPacket *) NULL))
+                    {
+                      i=Min(Max((long) (center+0.5),start),stop-1);
+                      j=y*(contribution[n-1].pixel-contribution[0].pixel+1)+
+                        (contribution[i-start].pixel-contribution[0].pixel);
+                      indexes[y]=source_indexes[j];
+                    }
                 }
-              else
+            }
+          else
+            {
+              for (y=0; y < (long) destination->rows; y++)
                 {
+                  double
+                    weight;
+
+                  DoublePixelPacket
+                    pixel=zero;
+
+                  long
+                    j;
+
+                  register long
+                    i;
+
                   for (i=0; i < n; i++)
                     {
                       j=(long) (y*(contribution[n-1].pixel-contribution[0].pixel+1)+
@@ -1024,15 +1049,15 @@
                   q[y].green=RoundDoubleToQuantum(pixel.green);
                   q[y].blue=RoundDoubleToQuantum(pixel.blue);
                   q[y].opacity=OpaqueOpacity;
-                }
 
-              if ((indexes != (IndexPacket *) NULL) &&
-                  (source_indexes != (IndexPacket *) NULL))
-                {
-                  i=Min(Max((long) (center+0.5),start),stop-1);
-                  j=y*(contribution[n-1].pixel-contribution[0].pixel+1)+
-                    (contribution[i-start].pixel-contribution[0].pixel);
-                  indexes[y]=source_indexes[j];
+                  if ((indexes != (IndexPacket *) NULL) &&
+                      (source_indexes != (IndexPacket *) NULL))
+                    {
+                      i=Min(Max((long) (center+0.5),start),stop-1);
+                      j=y*(contribution[n-1].pixel-contribution[0].pixel+1)+
+                        (contribution[i-start].pixel-contribution[0].pixel);
+                      indexes[y]=source_indexes[j];
+                    }
                 }
             }
           if (!SyncImagePixelsEx(destination,exception))
@@ -1101,6 +1126,9 @@
   MagickBool
     monitor_active;
 
+  const MagickBool
+    matte = ((destination->matte) || (destination->colorspace == CMYKColorspace));
+
   MagickPassFail
     status=MagickPass;
 
@@ -1220,26 +1248,23 @@
         {
           source_indexes=AccessImmutableIndexes(source);
           indexes=AccessMutableIndexes(destination);
-          for (x=0; x < (long) destination->columns; x++)
+          if (matte)
             {
-              double
-                weight;
-
-              DoublePixelPacket
-                pixel;
-
-              long
-                j;
-
-              register long
-                i;
-
-              pixel=zero;
-              if ((source->matte) || (source->colorspace == CMYKColorspace))
+              for (x=0; x < (long) destination->columns; x++)
                 {
                   double
                     transparency_coeff,
-                    normalize;
+                    normalize,
+                    weight;
+
+                  DoublePixelPacket
+                    pixel=zero;
+
+                  long
+                    j;
+
+                  register long
+                    i;
 
                   normalize=0.0;
                   for (i=0; i < n; i++)
@@ -1263,9 +1288,34 @@
                   q[x].green=RoundDoubleToQuantum(pixel.green);
                   q[x].blue=RoundDoubleToQuantum(pixel.blue);
                   q[x].opacity=RoundDoubleToQuantum(pixel.opacity);
+
+                  if ((indexes != (IndexPacket *) NULL) &&
+                      (source_indexes != (IndexPacket *) NULL))
+                    {
+                      i=Min(Max((long) (center+0.5),start),stop-1);
+                      j=(long) ((contribution[i-start].pixel-contribution[0].pixel)*
+                                source->columns+x);
+                      indexes[x]=source_indexes[j];
+                    }
                 }
-              else
+            }
+          else
+            {
+              for (x=0; x < (long) destination->columns; x++)
                 {
+                  double
+                    weight;
+
+                  DoublePixelPacket
+                    pixel;
+
+                  long
+                    j;
+
+                  register long
+                    i;
+
+                  pixel=zero;
                   for (i=0; i < n; i++)
                     {
                       j=(long) ((contribution[i].pixel-contribution[0].pixel)*
@@ -1279,15 +1329,15 @@
                   q[x].green=RoundDoubleToQuantum(pixel.green);
                   q[x].blue=RoundDoubleToQuantum(pixel.blue);
                   q[x].opacity=OpaqueOpacity;
-                }
 
-              if ((indexes != (IndexPacket *) NULL) &&
-                  (source_indexes != (IndexPacket *) NULL))
-                {
-                  i=Min(Max((long) (center+0.5),start),stop-1);
-                  j=(long) ((contribution[i-start].pixel-contribution[0].pixel)*
-                            source->columns+x);
-                  indexes[x]=source_indexes[j];
+                  if ((indexes != (IndexPacket *) NULL) &&
+                      (source_indexes != (IndexPacket *) NULL))
+                    {
+                      i=Min(Max((long) (center+0.5),start),stop-1);
+                      j=(long) ((contribution[i-start].pixel-contribution[0].pixel)*
+                                source->columns+x);
+                      indexes[x]=source_indexes[j];
+                    }
                 }
             }
           if (!SyncImagePixelsEx(destination,exception))
@@ -1410,7 +1460,7 @@
   if (resize_image == (Image *) NULL)
     return ((Image *) NULL);
 
-  order=(((double) columns*((size_t) image->rows+rows)) >
+  order=(((double) columns*((size_t) image->rows+rows)) >=
          ((double) rows*((size_t) image->columns+columns)));
   if (order)
     source_image=CloneImage(resize_image,columns,image->rows,True,exception);
diff -r 60b132017fce -r 5ccb2b5fc061 magick/version.h
--- a/magick/version.h	Sat Mar 18 18:16:06 2023 -0500
+++ b/magick/version.h	Sun Mar 19 14:41:43 2023 -0500
@@ -38,8 +38,8 @@
 #define MagickLibVersion  0x272402
 #define MagickLibVersionText  "1.4"
 #define MagickLibVersionNumber 27,24,2
-#define MagickChangeDate   "20230318"
-#define MagickReleaseDate  "snapshot-20230318"
+#define MagickChangeDate   "20230319"
+#define MagickReleaseDate  "snapshot-20230319"
 
 /*
   The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
diff -r 60b132017fce -r 5ccb2b5fc061 www/Changelog.html
--- a/www/Changelog.html	Sat Mar 18 18:16:06 2023 -0500
+++ b/www/Changelog.html	Sun Mar 19 14:41:43 2023 -0500
@@ -37,6 +37,13 @@
 </div>
 
 <div class="document">
+<p>2023-03-19  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>
+<ul class="simple">
+<li><p>magick/resize.c (ResizeImage): Clarify
+HorizontalFilter()/VerticalFilter() loops.</p></li>
+</ul>
+</blockquote>
 <p>2023-03-18  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;yandex&#46;com">JaFojtik<span>&#64;</span>yandex<span>&#46;</span>com</a>&gt;</p>
 <blockquote>
 <ul class="simple">
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.