]> Pileus Git - ~andy/gtk/commitdiff
Added translation to the rotate
authorMark Crichton <crichton@src.gnome.org>
Tue, 20 Jul 1999 18:59:39 +0000 (18:59 +0000)
committerMark Crichton <crichton@src.gnome.org>
Tue, 20 Jul 1999 18:59:39 +0000 (18:59 +0000)
Added translation to the rotate

demos/testpixbuf.c
gdk-pixbuf/ChangeLog
gdk-pixbuf/gdk-pixbuf.c

index 97a82f74a5f70a9fc7ae70ee2019caed2ae84197..cac9f0c6e2ca4d2e1a18530d216010377de8009b 100644 (file)
@@ -149,7 +149,7 @@ main (int argc, char **argv)
   for (i = 1; i < argc; i++)
     {
       pixbuf = gdk_pixbuf_load_image (argv[i]);
-      pixbuf = gdk_pixbuf_rotate(pixbuf, 42.0);
+      pixbuf = gdk_pixbuf_rotate(pixbuf, 10.0);
       
       if (pixbuf)
        {
index 1639f4409706c6b0c4220a8790e7ba6bcf62f620..fbff919043eb92c06ae7ef420c20fa7a03af6a37 100644 (file)
@@ -1,3 +1,8 @@
+1999-07-20  Mark Crichton  <crichton@gimp.org>
+
+       * src/gdk-pixbuf.c (gdk_pixbuf_rotate): Added translation to recenter
+       the pixbuf.  Unfortunately, it doesn't work right yet.
+
 1999-07-18  Larry Ewing  <lewing@gimp.org>
 
        * src/io-xpm.c:
index 1ab110557429fdeab2c4d1bef01900da6fe475e4..589d72fcba906f9b406fda0e31885b0c37c0f5c0 100644 (file)
@@ -1,8 +1,9 @@
 /*
  * gdk-pixbuf.c: Resource management.
  *
- * Author:
+ * Authors:
  *    Miguel de Icaza (miguel@gnu.org)
+ *    Mark Crichton (crichton@gimp.org)
  */
 #include <config.h>
 #include <glib.h>
@@ -84,20 +85,30 @@ gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle)
      art_u8 *pixels;
      gint rowstride, w, h;
      gdouble rad;
-     double affine[6];
+     double rot[6], trans[6], affine[6];
      ArtAlphaGamma *alphagamma = NULL;
      ArtPixBuf *art_pixbuf = NULL;
 
      w = pixbuf->art_pixbuf->width;
      h = pixbuf->art_pixbuf->height;
 
-     rad = M_PI * angle / 180.0;
+     rad = (M_PI * angle / 180.0);
 
-     affine[0] = cos(rad);
-     affine[1] = sin(rad);
-     affine[2] = -sin(rad);
-     affine[3] = cos(rad);
-     affine[4] = affine[5] = 0;
+     rot[0] = cos(rad);
+     rot[1] = sin(rad);
+     rot[2] = -sin(rad);
+     rot[3] = cos(rad);
+     rot[4] = rot[5] = 0;
+
+     trans[0] = trans[3] = 1;
+     trans[1] = trans[2] = 0;
+     trans[4] = (double)w / 2.0;
+     trans[5] = 0;
+
+     art_affine_multiply(affine, rot, trans);
+
+     g_print("Affine: %e %e %e %e %e %e\n", affine[0], affine[1], affine[2],
+            affine[3], affine[4], affine[5]);
 
      /* rowstride = w * pixbuf->art_pixbuf->n_channels; */
      rowstride = w * 3;
@@ -106,14 +117,14 @@ gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle)
      art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
                            pixbuf->art_pixbuf,
                            affine, ART_FILTER_NEAREST, alphagamma);
-      if (pixbuf->art_pixbuf->has_alpha)
-      /* should be rgba */
-      art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); 
-    else 
-      art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); 
+     if (pixbuf->art_pixbuf->has_alpha)
+         /* should be rgba */
+         art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); 
+     else 
+         art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); 
 
-    art_pixbuf_free (pixbuf->art_pixbuf);
-    pixbuf->art_pixbuf = art_pixbuf;
+     art_pixbuf_free (pixbuf->art_pixbuf);
+     pixbuf->art_pixbuf = art_pixbuf;
 
-    return pixbuf;
+     return pixbuf;
 }