summaryrefslogtreecommitdiff
path: root/graphics/gpaint/patches/11_fix_image_rotation.patch
blob: 4990b52c2861959299c21c31e30415ea83845bc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Author: Goedson Teixeira Paixao <goedson@debian.org>
Description: Fixes rotation operations
 Implement the rotation in multiples of 90 degrees using the
 gdk_pixbuf_rotate_simple function instead of the custom (and broken)
 rotation algorithm
Bug-Debian: http://bugs.debian.org/497487
Bug-Ubuntu: https://bugs.edge.launchpad.net/ubuntu/+source/gpaint/+bug/262942
Forwarded: https://savannah.gnu.org/patch/?6643

Index: b/src/drawing.c
===================================================================
--- a/src/drawing.c	2009-12-19 17:12:10.000000000 -0200
+++ b/src/drawing.c	2009-12-19 17:12:11.000000000 -0200
@@ -462,12 +462,23 @@
 }
 
 void
-drawing_rotate(gpaint_drawing *drawing, double degrees)
+drawing_rotate(gpaint_drawing *drawing, int degrees)
 {
     gpaint_image *image = drawing_create_image(drawing);
     if (image)
     {
-        image_rotate(image, degrees);    
+        switch (degrees)
+        {
+            case 0:
+            case 90:
+            case 180:
+            case 270:
+                image_rotate_simple(image, degrees);
+                break;
+            default:
+                image_rotate(image, degrees);
+                break;
+        }
         
         /* copy rotated image on the pixmap */
         gdk_pixmap_unref(drawing->backing_pixmap);
Index: b/src/drawing.h
===================================================================
--- a/src/drawing.h	2009-12-19 17:11:48.000000000 -0200
+++ b/src/drawing.h	2009-12-19 17:12:11.000000000 -0200
@@ -58,6 +58,6 @@
 void drawing_clear(gpaint_drawing *drawing);
 void drawing_clear_selection(gpaint_drawing *drawing, gpaint_point_array *points);
 gboolean drawing_prompt_to_save(gpaint_drawing *drawing);
-void drawing_rotate(gpaint_drawing *drawing, double degrees);
+void drawing_rotate(gpaint_drawing *drawing, int degrees);
 
 #endif
Index: b/src/image.c
===================================================================
--- a/src/image.c	2009-12-19 17:11:48.000000000 -0200
+++ b/src/image.c	2009-12-19 17:12:11.000000000 -0200
@@ -628,6 +628,27 @@
     return 0;
 }
 
+int
+image_rotate_simple (gpaint_image *image, int degrees)
+{
+	GdkPixbuf *newpixbuf;
+	
+	switch (degrees)
+	{
+        case GDK_PIXBUF_ROTATE_NONE:
+        case GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE:
+        case GDK_PIXBUF_ROTATE_UPSIDEDOWN:
+        case GDK_PIXBUF_ROTATE_CLOCKWISE:
+            newpixbuf = gdk_pixbuf_rotate_simple (image->pixbuf, degrees);
+            gdk_pixbuf_unref (image->pixbuf);
+            image->pixbuf = newpixbuf;
+            return 0;
+            break;
+        default:
+            return 1;
+    }
+}
+
 
 GdkPixbuf* image_pixbuf(gpaint_image* image) {
     return image->pixbuf;
Index: b/src/image.h
===================================================================
--- a/src/image.h	2009-12-19 17:11:48.000000000 -0200
+++ b/src/image.h	2009-12-19 17:12:11.000000000 -0200
@@ -45,5 +45,6 @@
 int            image_flip_x(gpaint_image *image);
 int            image_flip_y(gpaint_image *image);
 int            image_rotate(gpaint_image *image, double radians);
+int            image_rotate_simple(gpaint_image *image, int degrees);
 GdkPixbuf*     image_pixbuf(gpaint_image *image);
 #endif
Index: b/src/menu.c
===================================================================
--- a/src/menu.c	2009-12-19 17:12:10.000000000 -0200
+++ b/src/menu.c	2009-12-19 17:12:11.000000000 -0200
@@ -486,9 +486,9 @@
 
     sscanf(name, "rotate_%c%d_menu", &sign, &degrees);
     debug2("sign = %c  degrees = %d", sign, degrees);
-    if (sign=='n')
+    if (sign=='p')
     {
-        degrees *= -1;
+        degrees = 360 - degrees;
     }
     canvas_focus_lost(canvas);
     drawing_rotate(canvas->drawing, degrees);