[gthumb: 108/129] rotate tool: removed cropping from the rotation algorithm
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb: 108/129] rotate tool: removed cropping from the rotation algorithm
- Date: Wed, 27 Apr 2011 20:59:27 +0000 (UTC)
commit 4a75b01d933df3bf289ae1cbde7ef554d59ed5e7
Author: Stefano Pettini <spettini users sourceforge net>
Date: Fri Apr 22 12:56:27 2011 +0100
rotate tool: removed cropping from the rotation algorithm
extensions/file_tools/gdk-pixbuf-rotate.c | 23 ++++++++++++-----------
extensions/file_tools/gdk-pixbuf-rotate.h | 3 +--
extensions/file_tools/gth-file-tool-rotate.c | 2 +-
3 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/extensions/file_tools/gdk-pixbuf-rotate.c b/extensions/file_tools/gdk-pixbuf-rotate.c
index c9dffd7..9dd516c 100644
--- a/extensions/file_tools/gdk-pixbuf-rotate.c
+++ b/extensions/file_tools/gdk-pixbuf-rotate.c
@@ -24,10 +24,12 @@
#include "gdk-pixbuf-rotate.h"
+#define ROUND(x) (int) floor ((x) + 0.5)
+
+
static GdkPixbuf*
rotate (GdkPixbuf *src_pixbuf,
- double angle,
- gint auto_crop)
+ double angle)
{
GdkPixbuf *new_pixbuf;
@@ -52,8 +54,8 @@ rotate (GdkPixbuf *src_pixbuf,
src_width = gdk_pixbuf_get_width (src_pixbuf);
src_height = gdk_pixbuf_get_height (src_pixbuf);
- new_width = (int) floor ( cos_angle * src_width + fabs(sin_angle) * src_height + 0.5);
- new_height = (int) floor (fabs (sin_angle) * src_width + cos_angle * src_height + 0.5);
+ new_width = ROUND ( cos_angle * src_width + fabs(sin_angle) * src_height);
+ new_height = ROUND (fabs (sin_angle) * src_width + cos_angle * src_height);
new_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src_pixbuf),
gdk_pixbuf_get_has_alpha (src_pixbuf),
@@ -75,15 +77,15 @@ rotate (GdkPixbuf *src_pixbuf,
for (xi = 0; xi < new_width; xi++) {
- x = xi - (new_width - 1) / 2.0;
+ x = xi - (new_width - 1) / 2.0;
y = yi - (new_height - 1) / 2.0;
- x2 = cos_angle * x - sin_angle * y + (src_width - 1) / 2.0;
+ x2 = cos_angle * x - sin_angle * y + (src_width - 1) / 2.0;
y2 = sin_angle * x + cos_angle * y + (src_height - 1) / 2.0;
// TODO: interpolate
- x2i = (int) floor(x2 + 0.5);
- y2i = (int) floor(y2 + 0.5);
+ x2i = ROUND (x2);
+ y2i = ROUND (y2);
if (x2i >= 0 && x2i < src_width && y2i >= 0 && y2i < src_height) {
@@ -111,8 +113,7 @@ rotate (GdkPixbuf *src_pixbuf,
GdkPixbuf*
_gdk_pixbuf_rotate (GdkPixbuf *src_pixbuf,
- double angle,
- gint auto_crop)
+ double angle)
{
GdkPixbuf *new_pixbuf;
@@ -127,7 +128,7 @@ _gdk_pixbuf_rotate (GdkPixbuf *src_pixbuf,
new_pixbuf = gdk_pixbuf_rotate_simple (src_pixbuf, GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE);
}
else {
- new_pixbuf = rotate (src_pixbuf, -angle, auto_crop);
+ new_pixbuf = rotate (src_pixbuf, -angle);
}
return new_pixbuf;
diff --git a/extensions/file_tools/gdk-pixbuf-rotate.h b/extensions/file_tools/gdk-pixbuf-rotate.h
index 4566f5e..e0cc9c6 100644
--- a/extensions/file_tools/gdk-pixbuf-rotate.h
+++ b/extensions/file_tools/gdk-pixbuf-rotate.h
@@ -29,8 +29,7 @@
G_BEGIN_DECLS
GdkPixbuf* _gdk_pixbuf_rotate (GdkPixbuf *src_pixbuf,
- double angle,
- gint auto_crop);
+ double angle);
G_END_DECLS
diff --git a/extensions/file_tools/gth-file-tool-rotate.c b/extensions/file_tools/gth-file-tool-rotate.c
index ade07fb..1405500 100644
--- a/extensions/file_tools/gth-file-tool-rotate.c
+++ b/extensions/file_tools/gth-file-tool-rotate.c
@@ -121,7 +121,7 @@ apply_cb (gpointer user_data)
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);
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]