gnome-scan r528 - in trunk: . lib
- From: bersace svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-scan r528 - in trunk: . lib
- Date: Wed, 27 Feb 2008 17:05:41 +0000 (GMT)
Author: bersace
Date: Wed Feb 27 17:05:40 2008
New Revision: 528
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=528&view=rev
Log:
Move to gdouble rather than gint for paper size.
Modified:
trunk/ChangeLog
trunk/lib/gnome-scan-preview-plugin-area.c
trunk/lib/gnome-scan-utils.c
trunk/lib/gnome-scan-utils.h
Modified: trunk/lib/gnome-scan-preview-plugin-area.c
==============================================================================
--- trunk/lib/gnome-scan-preview-plugin-area.c (original)
+++ trunk/lib/gnome-scan-preview-plugin-area.c Wed Feb 27 17:05:40 2008
@@ -470,9 +470,9 @@
gdouble res = gnome_scan_preview_area_get_resolution (GNOME_SCAN_PREVIEW_AREA (gspp->preview_area));
/* origin */
- GdkPoint *o = gnome_scan_settings_get_pointer (s, "origin");
- o->x = r.x;
- o->y = r.y;
+ GSPoint *o = gnome_scan_settings_get_pointer (s, "origin");
+ o->x = gs_convert_to_mm (r.x, GS_UNIT_PIXEL, res);
+ o->y = gs_convert_to_mm(r.y, GS_UNIT_PIXEL, res);
/* paper-size (if manual) */
GtkPaperSize *p = gnome_scan_settings_get_boxed (s, "paper-size",
@@ -493,7 +493,7 @@
}
else if (g_str_equal (gtk_paper_size_get_name (p), "maximal")) {
/* set origin to (0,0) for maximal paper-size */
- o->x = o->y = 0;
+ o->x = o->y = 0.;
}
gnome_scan_settings_set_pointer (s, "origin", o);
@@ -511,7 +511,7 @@
static void
gsppa_set_roi (GnomeScanPreviewPlugin *gspp)
{
- GdkPoint *p;
+ GSPoint *p;
GtkPaperSize *ps;
GtkPageOrientation o;
gint tmp;
@@ -525,18 +525,18 @@
o = gnome_scan_settings_get_enum(gspp->settings, "page-orientation",
GTK_TYPE_PAGE_ORIENTATION);
if (!p) {
- p = g_new0 (GdkPoint, 1);
+ p = g_new0 (GSPoint, 1);
gnome_scan_settings_set_pointer (gspp->settings, "origin", p);
}
- r.x = p->x;
- r.y = p->y;
+ r.x = gs_convert_from_mm (p->x, GS_UNIT_PIXEL, res);
+ r.y = gs_convert_from_mm (p->y, GS_UNIT_PIXEL, res);
ps = gnome_scan_settings_get_boxed (gspp->settings, "paper-size",
GTK_TYPE_PAPER_SIZE);
- r.width = (gint) gs_convert (gtk_paper_size_get_width (ps, GTK_UNIT_MM), GTK_UNIT_MM, GS_UNIT_PIXEL, res);
- r.height = (gint) gs_convert (gtk_paper_size_get_height (ps, GTK_UNIT_MM), GTK_UNIT_MM, GS_UNIT_PIXEL, res);
+ r.width = (gint) gs_convert_from_mm (gtk_paper_size_get_width (ps, GTK_UNIT_MM), GS_UNIT_PIXEL, res);
+ r.height = (gint) gs_convert_from_mm (gtk_paper_size_get_height (ps, GTK_UNIT_MM), GS_UNIT_PIXEL, res);
switch(o) {
case GTK_PAGE_ORIENTATION_LANDSCAPE:
Modified: trunk/lib/gnome-scan-utils.c
==============================================================================
--- trunk/lib/gnome-scan-utils.c (original)
+++ trunk/lib/gnome-scan-utils.c Wed Feb 27 17:05:40 2008
@@ -30,7 +30,7 @@
#define GS_WARN_UNSUPPORTED_UNIT(unit) g_warning("%s: Unsupported unit %s.", __FUNCTION__, gs_enum_get_nick_from_value (GNOME_TYPE_SCAN_UNIT, unit))
-static const gchar*
+const gchar*
gs_enum_get_nick_from_value (GType type, guint value)
{
GEnumClass *klass;
@@ -127,8 +127,8 @@
}
}
-GdkRectangle*
-gs_rectangle_convert (GdkRectangle *r,
+GSRectangle*
+gs_rectangle_convert (GSRectangle *r,
GnomeScanUnit from,
GnomeScanUnit to,
gdouble res)
@@ -137,12 +137,12 @@
to, res);
}
-GdkRectangle*
-gs_rectangle_convert_to_mm (GdkRectangle *r,
+GSRectangle*
+gs_rectangle_convert_to_mm (GSRectangle *r,
GnomeScanUnit unit,
gdouble res)
{
- GdkRectangle *rect = g_new0 (GdkRectangle, 1);
+ GSRectangle*rect = g_new0 (GSRectangle, 1);
#define conv(var) rect->var = gs_convert_to_mm (r->var, unit, res)
conv(x);
conv(y);
@@ -152,12 +152,12 @@
return rect;
}
-GdkRectangle*
-gs_rectangle_convert_from_mm (GdkRectangle *r,
+GSRectangle*
+gs_rectangle_convert_from_mm (GSRectangle *r,
GnomeScanUnit unit,
gdouble res)
{
- GdkRectangle *rect = g_new0 (GdkRectangle, 1);
+ GSRectangle*rect = g_new0 (GSRectangle, 1);
#define conv(var) rect->var = gs_convert_from_mm (r->var, unit, res)
conv(x);
conv(y);
@@ -166,3 +166,39 @@
#undef conv
return rect;
}
+
+GSRectangle*
+gs_rectangle_rotate(GSRectangle *r,
+ GSRectangle *a,
+ guint angle)
+{
+ GSRectangle *res = g_memdup(r, sizeof(GSRectangle));
+ angle%= 360;
+
+ switch (angle)
+ {
+ case 0:
+ break;
+ case 270:
+ res->width = r->height;
+ res->height = r->width;
+ res->x = r->y;
+ res->y = MAX(a->width - r->x - r->width, a->x);
+ break;
+ case 180:
+ res->x = MAX(a->width - r->x - r->width, a->x);
+ res->y = MAX(a->height - r->y - r->height, a->y);
+ break;
+ case 90:
+ res->width = r->height;
+ res->height = r->width;
+ res->y = r->x;
+ res->x = MAX(a->height - r->y - r->height, a->y);
+ break;
+ default:
+ g_warning("%s: %i degree rotation is not supported",
+ __FUNCTION__, angle);
+ break;
+ }
+ return res;
+}
Modified: trunk/lib/gnome-scan-utils.h
==============================================================================
--- trunk/lib/gnome-scan-utils.h (original)
+++ trunk/lib/gnome-scan-utils.h Wed Feb 27 17:05:40 2008
@@ -79,6 +79,22 @@
gchar **extensions;
};
+typedef struct _GSPoint GSPoint;
+struct _GSPoint
+{
+ gdouble x;
+ gdouble y;
+};
+
+typedef struct _GSRectangle GSRectangle;
+struct _GSRectangle
+{
+ gdouble x;
+ gdouble y;
+ gdouble width;
+ gdouble height;
+};
+
/**
* GnomeScanUnit:
**/
@@ -94,6 +110,9 @@
GS_UNIT_MICROSECOND
} GnomeScanUnit;
+const gchar*
+gs_enum_get_nick_from_value (GType type, guint value);
+
gdouble gs_convert (gdouble val,
GnomeScanUnit from,
GnomeScanUnit to,
@@ -107,18 +126,25 @@
GnomeScanUnit unit,
gdouble res);
-GdkRectangle* gs_rectangle_convert (GdkRectangle *r,
+GSRectangle* gs_rectangle_convert (GSRectangle *r,
GnomeScanUnit from,
GnomeScanUnit to,
gdouble res);
-GdkRectangle* gs_rectangle_convert_to_mm (GdkRectangle *r,
+GSRectangle* gs_rectangle_convert_to_mm (GSRectangle *r,
GnomeScanUnit unit,
gdouble res);
-GdkRectangle* gs_rectangle_convert_from_mm (GdkRectangle *r,
+GSRectangle* gs_rectangle_convert_from_mm (GSRectangle *r,
GnomeScanUnit unit,
gdouble res);
+GSRectangle* gs_rectangle_rotate (GSRectangle *r,
+ GSRectangle *a,
+ guint angle);
+
+#define gs_debug_rect(r) g_debug(G_STRLOC ": " #r " = %ix%i+%i+%i", (r)->width, (r)->height, (r)->x, (r)->y)
+#define gs_debug_gsrect(r) g_debug(G_STRLOC ": " #r " = %.2fx%.2f+%.2f+%.2f", (r)->width, (r)->height, (r)->x, (r)->y)
+
G_END_DECLS
#endif /* _GNOME_SCAN_UTILS_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]