[gthumb: 115/129] rotate tool: minor improvements



commit 80a58594285526417b887ad095a01522c9c2e96a
Author: Stefano Pettini <spettini users sourceforge net>
Date:   Mon Apr 25 01:34:44 2011 +0100

    rotate tool: minor improvements

 extensions/file_tools/gdk-pixbuf-rotate.c    |   23 +++++++++------------
 extensions/file_tools/gdk-pixbuf-rotate.h    |   17 ++++++---------
 extensions/file_tools/gth-file-tool-rotate.c |   27 +++++++------------------
 3 files changed, 25 insertions(+), 42 deletions(-)
---
diff --git a/extensions/file_tools/gdk-pixbuf-rotate.c b/extensions/file_tools/gdk-pixbuf-rotate.c
index 67e7125..58a76a0 100644
--- a/extensions/file_tools/gdk-pixbuf-rotate.c
+++ b/extensions/file_tools/gdk-pixbuf-rotate.c
@@ -78,15 +78,12 @@ _gdk_pixbuf_rotate_get_cropping_parameters (GdkPixbuf *src_pixbuf,
 
 void
 _gdk_pixbuf_rotate_get_cropping_region (GdkPixbuf *src_pixbuf,
-					double     angle,
-					double     alpha,
-					double     beta,
-					double     gamma,
-					double     delta,
-					int       *x,
-					int       *y,
-					int       *width,
-					int       *height)
+					double        angle,
+					double        alpha,
+					double        beta,
+					double        gamma,
+					double        delta,
+					GdkRectangle *region)
 {
 	double angle_rad;
 	double cos_angle, sin_angle;
@@ -133,11 +130,11 @@ _gdk_pixbuf_rotate_get_cropping_region (GdkPixbuf *src_pixbuf,
 		xx2 = new_width - xx2;
 	}
 
-	*x = ROUND (MIN (xx1, xx2));
-	*y = ROUND (MIN (yy1, yy2));
+	region->x = ROUND (MIN (xx1, xx2));
+	region->y = ROUND (MIN (yy1, yy2));
 	
-	*width  = ROUND (MAX (xx1, xx2)) - *x;
-	*height = ROUND (MAX (yy1, yy2)) - *y;
+	region->width  = ROUND (MAX (xx1, xx2)) - region->x + 1;
+	region->height = ROUND (MAX (yy1, yy2)) - region->y + 1;
 }
 
 
diff --git a/extensions/file_tools/gdk-pixbuf-rotate.h b/extensions/file_tools/gdk-pixbuf-rotate.h
index 74b76bd..3e8dd57 100644
--- a/extensions/file_tools/gdk-pixbuf-rotate.h
+++ b/extensions/file_tools/gdk-pixbuf-rotate.h
@@ -33,16 +33,13 @@ void _gdk_pixbuf_rotate_get_cropping_parameters (GdkPixbuf *src_pixbuf,
 					         double    *alpha_plus_beta,
 					         double    *gamma_plus_delta);
 
-void _gdk_pixbuf_rotate_get_cropping_region (GdkPixbuf *src_pixbuf,
-					     double     angle,
-					     double     alpha,
-					     double     beta,
-					     double     gamma,
-					     double     delta,
-					     int       *x,
-					     int       *y,
-					     int       *width,
-					     int       *height);
+void _gdk_pixbuf_rotate_get_cropping_region (GdkPixbuf    *src_pixbuf,
+					     double        angle,
+					     double        alpha,
+					     double        beta,
+					     double        gamma,
+					     double        delta,
+					     GdkRectangle *region);
 
 GdkPixbuf* _gdk_pixbuf_rotate (GdkPixbuf *src_pixbuf,
 			       double     angle,
diff --git a/extensions/file_tools/gth-file-tool-rotate.c b/extensions/file_tools/gth-file-tool-rotate.c
index baf0a03..b75bddd 100644
--- a/extensions/file_tools/gth-file-tool-rotate.c
+++ b/extensions/file_tools/gth-file-tool-rotate.c
@@ -52,10 +52,7 @@ struct _GthFileToolRotatePrivate {
 	GthImageSelector *selector_align;
 	guint             selector_align_point;
 	guint             apply_event;
-	int               crop_x;
-	int               crop_y;
-	int               crop_width;
-	int               crop_height;
+	GdkRectangle      crop_region;
 };
 
 
@@ -136,10 +133,10 @@ crop_button_clicked_cb (GtkButton         *button,
 	GdkPixbuf *temp_pixbuf;
 	
 	temp_pixbuf = gdk_pixbuf_new_subpixbuf (self->priv->dest_pixbuf,
-						self->priv->crop_x,
-						self->priv->crop_y,
-						self->priv->crop_width,
-						self->priv->crop_height);
+						self->priv->crop_region.x,
+						self->priv->crop_region.y,
+						self->priv->crop_region.width,
+						self->priv->crop_region.height);
 	
 	_g_object_unref (self->priv->dest_pixbuf);
 	self->priv->dest_pixbuf = temp_pixbuf;
@@ -219,7 +216,7 @@ update_crop_region (gpointer user_data)
 	enable_guided_crop = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->priv->enable_guided_crop));
 
 	if (enable_guided_crop) {
-
+		
 		gtk_widget_set_sensitive (GTK_WIDGET (self->priv->keep_aspect_ratio), TRUE);
 		gtk_widget_set_sensitive (GET_WIDGET ("crop_button"), TRUE);
 		
@@ -251,19 +248,11 @@ update_crop_region (gpointer user_data)
 		
 		_gdk_pixbuf_rotate_get_cropping_region (self->priv->src_pixbuf, rotation_angle,
 							crop_alpha, crop_beta, crop_gamma, crop_delta,
-							&self->priv->crop_x,
-							&self->priv->crop_y,
-							&self->priv->crop_width,
-							&self->priv->crop_height);
+							&self->priv->crop_region);
 
 		gth_image_viewer_set_tool (GTH_IMAGE_VIEWER (viewer), (GthImageViewerTool *) self->priv->selector_crop);
 
-		gth_image_selector_set_selection_pos (self->priv->selector_crop,
-						      self->priv->crop_x,
-						      self->priv->crop_y);
-						      
-		gth_image_selector_set_selection_width  (self->priv->selector_crop, self->priv->crop_width);
-		gth_image_selector_set_selection_height (self->priv->selector_crop, self->priv->crop_height);
+		gth_image_selector_set_selection (self->priv->selector_crop, self->priv->crop_region);
 	}
 	else {
 		gth_image_viewer_set_tool (GTH_IMAGE_VIEWER (viewer), NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]