GM 1.1.9 -rotate 270 bug

Bob Friesenhahn <[email protected]> Tue, 18 Sep 2007 22:47:43 -0500 (CDT)
Newsgroups gmane.comp.video.graphicsmagick.announce
Message-ID <[email protected]>
Today I learned that there is a bug in the new rotate code introduced 
in GraphicsMagick 1.1.9.  It only impacts rotation by -90/270 degrees. 
While the output looks nice, it is wrong.

I will be releasing 1.1.10 in the next few days in order to address 
this situation.

For those of you who are familiar with compiling source code and using 
'patch', I have attached a patch to fix this bug in 1.1.9.

Bob
======================================
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

Index: shear.c
===================================================================
RCS file: /GraphicsMagick/GraphicsMagick/magick/shear.c,v
retrieving revision 1.144.2.1
diff -u -r1.144.2.1 shear.c
--- shear.c	12 Sep 2007 21:32:53 -0000	1.144.2.1
+++ shear.c	19 Sep 2007 03:07:43 -0000
@@ -531,13 +531,17 @@
      case 3:
        {
          /*
-          Rotate 180 degrees.
+          Rotate 270 degrees.
          */
          status=MagickPass;
          for (tile_y=0; tile_y < (long) image->rows; tile_y+=tile_height_max)
            {
              for (tile_x=0; tile_x < (long) image->columns; tile_x+=tile_width_max)
                {
+                long
+                  dest_tile_x,
+                  dest_tile_y;
+
                  /*
                    Compute image region corresponding to tile.
                  */
@@ -560,11 +564,16 @@
                      break;
                    }
                  /*
+                  Compute destination tile coordinates.
+                */
+                dest_tile_x=tile_y;
+                dest_tile_y=rotate_image->rows-(tile_x+tile_width);
+                /*
                    Rotate tile
                  */
-                for (y=tile_width-1; y >= 0; y--)
+                for (y=0; y < tile_width; y++)
                    {
-                    q=SetImagePixels(rotate_image,tile_y,tile_x+y,tile_height,1);
+                    q=SetImagePixels(rotate_image,dest_tile_x,dest_tile_y+y,tile_height,1);
                      if (q == (PixelPacket *) NULL)
                        {
                          status=MagickFail;
@@ -573,8 +582,8 @@
                      /*
                        DirectClass pixels
                      */
-                    p=tile_pixels+y;
-                    for (x=0; x < tile_height; x++)
+                    p=tile_pixels+(tile_width-1-y);
+                    for (x=tile_height; x != 0; x--)
                        {
                          *q = *p;
                          q++;
@@ -590,8 +599,8 @@
                          if (rotate_indexes != (IndexPacket *) NULL)
                            {
                              iq=rotate_indexes;
-                            ip=indexes+y;
-                            for (x=0; x < tile_height; x++)
+                            ip=indexes+(tile_width-1-y);
+                            for (x=tile_height; x != 0; x--)
                                {
                                  *iq = *ip;
                                  iq++;

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/