[gthumb: 101/129] rotate tool: Added center of rotation
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb: 101/129] rotate tool: Added center of rotation
- Date: Wed, 27 Apr 2011 20:58:52 +0000 (UTC)
commit 4ab76b188967cecc4427aa5d8dea5ca3013c58f8
Author: Stefano Pettini <spettini users sourceforge net>
Date: Wed Apr 20 17:18:12 2011 +0100
rotate tool: Added center of rotation
extensions/file_tools/gdk-pixbuf-rotate.c | 42 +++++++++++++++++++++----
extensions/file_tools/gdk-pixbuf-rotate.h | 2 +
extensions/file_tools/gth-file-tool-rotate.c | 9 ++++-
3 files changed, 44 insertions(+), 9 deletions(-)
---
diff --git a/extensions/file_tools/gdk-pixbuf-rotate.c b/extensions/file_tools/gdk-pixbuf-rotate.c
index b90dcb9..96fb73c 100644
--- a/extensions/file_tools/gdk-pixbuf-rotate.c
+++ b/extensions/file_tools/gdk-pixbuf-rotate.c
@@ -24,22 +24,50 @@
GdkPixbuf*
+_gdk_pixbuf_rotate_crop (GdkPixbuf *src_pixbuf,
+ int center_x,
+ int center_y,
+ double angle)
+{
+ // TODO: implement the algorithm
+
+ g_object_ref (src_pixbuf);
+ return src_pixbuf;
+}
+
+
+GdkPixbuf*
+_gdk_pixbuf_rotate_no_crop (GdkPixbuf *src_pixbuf,
+ int center_x,
+ int center_y,
+ double angle)
+{
+ // TODO: implement the algorithm
+
+ g_object_ref (src_pixbuf);
+ return src_pixbuf;
+}
+
+
+GdkPixbuf*
_gdk_pixbuf_rotate (GdkPixbuf *src_pixbuf,
+ int center_x,
+ int center_y,
double angle,
gint auto_crop)
{
GdkPixbuf *new_pixbuf;
- if (angle > 45.0) {
- new_pixbuf = _gdk_pixbuf_transform (src_pixbuf, GTH_TRANSFORM_ROTATE_90);
+ if (angle == 0.0) {
+ new_pixbuf = src_pixbuf;
+ g_object_ref (new_pixbuf);
}
- else if (angle < -45.0) {
- new_pixbuf = _gdk_pixbuf_transform (src_pixbuf, GTH_TRANSFORM_ROTATE_270);
+ else if (auto_crop) {
+ new_pixbuf = _gdk_pixbuf_rotate_crop (src_pixbuf, center_x, center_y, angle);
}
else {
- new_pixbuf = src_pixbuf;
- g_object_ref (new_pixbuf);
+ new_pixbuf = _gdk_pixbuf_rotate_no_crop (src_pixbuf, center_x, center_y, angle);
}
-
+
return new_pixbuf;
}
diff --git a/extensions/file_tools/gdk-pixbuf-rotate.h b/extensions/file_tools/gdk-pixbuf-rotate.h
index 4566f5e..8749bc4 100644
--- a/extensions/file_tools/gdk-pixbuf-rotate.h
+++ b/extensions/file_tools/gdk-pixbuf-rotate.h
@@ -29,6 +29,8 @@
G_BEGIN_DECLS
GdkPixbuf* _gdk_pixbuf_rotate (GdkPixbuf *src_pixbuf,
+ int center_x,
+ int center_y,
double angle,
gint auto_crop);
diff --git a/extensions/file_tools/gth-file-tool-rotate.c b/extensions/file_tools/gth-file-tool-rotate.c
index c4db81b..2747105 100644
--- a/extensions/file_tools/gth-file-tool-rotate.c
+++ b/extensions/file_tools/gth-file-tool-rotate.c
@@ -107,6 +107,8 @@ apply_cb (gpointer user_data)
GtkWidget *window;
GtkWidget *viewer_page;
double rotation_angle;
+ int center_x;
+ int center_y;
gint auto_crop;
if (self->priv->apply_event != 0) {
@@ -118,11 +120,14 @@ apply_cb (gpointer user_data)
viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
rotation_angle = gtk_adjustment_get_value (self->priv->rotation_angle_adj);
- auto_crop = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->auto_crop));
if (rotation_angle != 0.0) {
+ center_x = self->priv->pixbuf_width / 2;
+ center_y = self->priv->pixbuf_height / 2;
+ auto_crop = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->auto_crop));
+
_g_object_unref (self->priv->dest_pixbuf);
- self->priv->dest_pixbuf = _gdk_pixbuf_rotate (self->priv->src_pixbuf, rotation_angle, auto_crop);
+ self->priv->dest_pixbuf = _gdk_pixbuf_rotate (self->priv->src_pixbuf, rotation_angle, center_x, center_y, auto_crop);
gth_image_viewer_page_set_pixbuf (GTH_IMAGE_VIEWER_PAGE (viewer_page), self->priv->dest_pixbuf, FALSE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]