summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Crichton <crichton@src.gnome.org>1999-07-20 18:59:39 +0000
committerMark Crichton <crichton@src.gnome.org>1999-07-20 18:59:39 +0000
commit8194b3483bbb2ccce7b9433b9142dc5725247e35 (patch)
tree66d049720579c27becbcfc56fad29ab8443758e4
parente0fe9318327b8c08d56774d70eb9802c5af14024 (diff)
downloadgtk+-8194b3483bbb2ccce7b9433b9142dc5725247e35.tar.gz
Added translation to the rotate
Added translation to the rotate
-rw-r--r--demos/testpixbuf.c2
-rw-r--r--gdk-pixbuf/ChangeLog5
-rw-r--r--gdk-pixbuf/gdk-pixbuf.c43
3 files changed, 33 insertions, 17 deletions
diff --git a/demos/testpixbuf.c b/demos/testpixbuf.c
index 97a82f74a5..cac9f0c6e2 100644
--- a/demos/testpixbuf.c
+++ b/demos/testpixbuf.c
@@ -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)
{
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index 1639f44097..fbff919043 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -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:
diff --git a/gdk-pixbuf/gdk-pixbuf.c b/gdk-pixbuf/gdk-pixbuf.c
index 1ab1105574..589d72fcba 100644
--- a/gdk-pixbuf/gdk-pixbuf.c
+++ b/gdk-pixbuf/gdk-pixbuf.c
@@ -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;
}