[Rawstudio-commit] r2042 - trunk/src
Anders Brander
anders at brander.dk
Mon Sep 29 01:57:17 CEST 2008
Author: abrander
Date: 2008-09-29 01:57:16 +0200 (Mon, 29 Sep 2008)
New Revision: 2042
Modified:
trunk/src/rawstudio.c
trunk/src/rawstudio.h
trunk/src/rs-photo.c
trunk/src/rs-preview-widget.c
trunk/src/rs-utils.c
trunk/src/rs-utils.h
Log:
Moved rs_rect_*()-functions to rs-utils.c.
Modified: trunk/src/rawstudio.c
===================================================================
--- trunk/src/rawstudio.c 2008-09-28 23:49:24 UTC (rev 2041)
+++ trunk/src/rawstudio.c 2008-09-28 23:57:16 UTC (rev 2042)
@@ -635,128 +635,6 @@
}
void
-rs_rect_normalize(RS_RECT *in, RS_RECT *out)
-{
- gint n;
- gint x1,y1;
- gint x2,y2;
-
- x1 = in->x2;
- x2 = in->x1;
- y1 = in->y1;
- y2 = in->y2;
-
- if (x1>x2)
- {
- n = x1;
- x1 = x2;
- x2 = n;
- }
- if (y1>y2)
- {
- n = y1;
- y1 = y2;
- y2 = n;
- }
-
- out->x1 = x1;
- out->x2 = x2;
- out->y1 = y1;
- out->y2 = y2;
-}
-
-void
-rs_rect_flip(RS_RECT *in, RS_RECT *out, gint w, gint h)
-{
- gint x1,y1;
- gint x2,y2;
-
- x1 = in->x1;
- x2 = in->x2;
- y1 = h - in->y2 - 1;
- y2 = h - in->y1 - 1;
-
- out->x1 = x1;
- out->x2 = x2;
- out->y1 = y1;
- out->y2 = y2;
- rs_rect_normalize(out, out);
-
- return;
-}
-
-void
-rs_rect_mirror(RS_RECT *in, RS_RECT *out, gint w, gint h)
-{
- gint x1,y1;
- gint x2,y2;
-
- x1 = w - in->x2 - 1;
- x2 = w - in->x1 - 1;
- y1 = in->y1;
- y2 = in->y2;
-
- out->x1 = x1;
- out->x2 = x2;
- out->y1 = y1;
- out->y2 = y2;
- rs_rect_normalize(out, out);
-
- return;
-}
-
-void
-rs_rect_rotate(RS_RECT *in, RS_RECT *out, gint w, gint h, gint quarterturns)
-{
- gint x1,y1;
- gint x2,y2;
-
- x1 = in->x2;
- x2 = in->x1;
- y1 = in->y1;
- y2 = in->y2;
-
- switch(quarterturns)
- {
- case 1:
- x1 = h - in->y1-1;
- x2 = h - in->y2-1;
- y1 = in->x1;
- y2 = in->x2;
- break;
- case 2:
- x1 = w - in->x1 - 1;
- x2 = w - in->x2 - 1;
- y1 = h - in->y1 - 1;
- y2 = h - in->y2 - 1;
- break;
- case 3:
- x1 = in->y1;
- x2 = in->y2;
- y1 = w - in->x1 - 1;
- y2 = w - in->x2 - 1;
- break;
- }
-
- out->x1 = x1;
- out->x2 = x2;
- out->y1 = y1;
- out->y2 = y2;
- rs_rect_normalize(out, out);
-
- return;
-}
-
-inline void
-rs_rect_from_gdkrectangle(GdkRectangle *in, RS_RECT *out)
-{
- out->x1 = in->x;
- out->y1 = in->y;
- out->x2 = in->x+in->width;
- out->y2 = in->y+in->height;
-}
-
-void
check_install()
{
#define TEST_FILE_ACCESS(path) do { if (g_access(path, R_OK)!=0) g_debug("Cannot access %s\n", path);} while (0)
Modified: trunk/src/rawstudio.h
===================================================================
--- trunk/src/rawstudio.h 2008-09-28 23:49:24 UTC (rev 2041)
+++ trunk/src/rawstudio.h 2008-09-28 23:57:16 UTC (rev 2042)
@@ -234,11 +234,7 @@
void rs_white_black_point(RS_BLOB *rs);
void rs_render_pixel_to_srgb(RS_BLOB *rs, gint x, gint y, guchar *dest);
void rs_apply_settings_from_double(RS_SETTINGS *rss, RS_SETTINGS_DOUBLE *rsd, gint mask);
-void rs_rect_normalize(RS_RECT *in, RS_RECT *out);
gboolean rs_has_gimp(gint major, gint minor, gint micro);
-void rs_rect_flip(RS_RECT *in, RS_RECT *out, gint w, gint h);
-void rs_rect_mirror(RS_RECT *in, RS_RECT *out, gint w, gint h);
-void rs_rect_rotate(RS_RECT *in, RS_RECT *out, gint w, gint h, gint quarterturns);
/* Contains a list of supported filetypes */
extern RS_FILETYPE *filetypes;
Modified: trunk/src/rs-photo.c
===================================================================
--- trunk/src/rs-photo.c 2008-09-28 23:49:24 UTC (rev 2041)
+++ trunk/src/rs-photo.c 2008-09-28 23:57:16 UTC (rev 2042)
@@ -25,6 +25,7 @@
#include "rs-preload.h"
#include "rs-metadata.h"
#include "rs-filetypes.h"
+#include "rs-utils.h"
static void rs_photo_class_init (RS_PHOTOClass *klass);
Modified: trunk/src/rs-preview-widget.c
===================================================================
--- trunk/src/rs-preview-widget.c 2008-09-28 23:49:24 UTC (rev 2041)
+++ trunk/src/rs-preview-widget.c 2008-09-28 23:57:16 UTC (rev 2042)
@@ -32,6 +32,7 @@
#include "rs-actions.h"
#include "rs-job.h"
#include "rs-metadata.h" /* FIXME: Remove this line and add rs_metadata_get_adobe_matrix() */
+#include "rs-utils.h"
#include <gettext.h>
typedef enum {
Modified: trunk/src/rs-utils.c
===================================================================
--- trunk/src/rs-utils.c 2008-09-28 23:49:24 UTC (rev 2041)
+++ trunk/src/rs-utils.c 2008-09-28 23:57:16 UTC (rev 2042)
@@ -232,3 +232,137 @@
g_string_free(dotdir, FALSE);
return (ret);
}
+
+/**
+ * Normalize a RS_RECT, ie makes sure that x1 < x2 and y1<y2
+ * @param in A RS_RECT to read values from
+ * @param out A RS_RECT to write the values to (can be the same as in)
+ */
+void
+rs_rect_normalize(RS_RECT *in, RS_RECT *out)
+{
+ gint n;
+ gint x1,y1;
+ gint x2,y2;
+
+ x1 = in->x2;
+ x2 = in->x1;
+ y1 = in->y1;
+ y2 = in->y2;
+
+ if (x1>x2)
+ {
+ n = x1;
+ x1 = x2;
+ x2 = n;
+ }
+ if (y1>y2)
+ {
+ n = y1;
+ y1 = y2;
+ y2 = n;
+ }
+
+ out->x1 = x1;
+ out->x2 = x2;
+ out->y1 = y1;
+ out->y2 = y2;
+}
+
+/**
+ * Flip a RS_RECT
+ * @param in A RS_RECT to read values from
+ * @param out A RS_RECT to write the values to (can be the same as in)
+ * @param w The width of the data OUTSIDE the RS_RECT
+ * @param h The height of the data OUTSIDE the RS_RECT
+ */
+void
+rs_rect_flip(RS_RECT *in, RS_RECT *out, gint w, gint h)
+{
+ gint x1,y1;
+ gint x2,y2;
+
+ x1 = in->x1;
+ x2 = in->x2;
+ y1 = h - in->y2 - 1;
+ y2 = h - in->y1 - 1;
+
+ out->x1 = x1;
+ out->x2 = x2;
+ out->y1 = y1;
+ out->y2 = y2;
+ rs_rect_normalize(out, out);
+}
+
+/**
+ * Mirrors a RS_RECT
+ * @param in A RS_RECT to read values from
+ * @param out A RS_RECT to write the values to (can be the same as in)
+ * @param w The width of the data OUTSIDE the RS_RECT
+ * @param h The height of the data OUTSIDE the RS_RECT
+ */
+void
+rs_rect_mirror(RS_RECT *in, RS_RECT *out, gint w, gint h)
+{
+ gint x1,y1;
+ gint x2,y2;
+
+ x1 = w - in->x2 - 1;
+ x2 = w - in->x1 - 1;
+ y1 = in->y1;
+ y2 = in->y2;
+
+ out->x1 = x1;
+ out->x2 = x2;
+ out->y1 = y1;
+ out->y2 = y2;
+ rs_rect_normalize(out, out);
+}
+
+/**
+ * Rotate a RS_RECT in 90 degrees steps
+ * @param in A RS_RECT to read values from
+ * @param out A RS_RECT to write the values to (can be the same as in)
+ * @param w The width of the data OUTSIDE the RS_RECT
+ * @param h The height of the data OUTSIDE the RS_RECT
+ * @param quarterturns How many times to turn the rect clockwise
+ */
+void
+rs_rect_rotate(RS_RECT *in, RS_RECT *out, gint w, gint h, gint quarterturns)
+{
+ gint x1,y1;
+ gint x2,y2;
+
+ x1 = in->x2;
+ x2 = in->x1;
+ y1 = in->y1;
+ y2 = in->y2;
+
+ switch(quarterturns)
+ {
+ case 1:
+ x1 = h - in->y1-1;
+ x2 = h - in->y2-1;
+ y1 = in->x1;
+ y2 = in->x2;
+ break;
+ case 2:
+ x1 = w - in->x1 - 1;
+ x2 = w - in->x2 - 1;
+ y1 = h - in->y1 - 1;
+ y2 = h - in->y2 - 1;
+ break;
+ case 3:
+ x1 = in->y1;
+ x2 = in->y2;
+ y1 = w - in->x1 - 1;
+ y2 = w - in->x2 - 1;
+ break;
+ }
+
+ out->x1 = x1;
+ out->x2 = x2;
+ out->y1 = y1;
+ out->y2 = y2;
+ rs_rect_normalize(out, out);
+}
Modified: trunk/src/rs-utils.h
===================================================================
--- trunk/src/rs-utils.h 2008-09-28 23:49:24 UTC (rev 2041)
+++ trunk/src/rs-utils.h 2008-09-28 23:57:16 UTC (rev 2042)
@@ -82,4 +82,43 @@
extern gchar *
rs_dotdir_get(const gchar *filename);
+/**
+ * Normalize a RS_RECT, ie makes sure that x1 < x2 and y1<y2
+ * @param in A RS_RECT to read values from
+ * @param out A RS_RECT to write the values to (can be the same as in)
+ */
+extern void
+rs_rect_normalize(RS_RECT *in, RS_RECT *out);
+
+/**
+ * Flip a RS_RECT
+ * @param in A RS_RECT to read values from
+ * @param out A RS_RECT to write the values to (can be the same as in)
+ * @param w The width of the data OUTSIDE the RS_RECT
+ * @param h The height of the data OUTSIDE the RS_RECT
+ */
+extern void
+rs_rect_flip(RS_RECT *in, RS_RECT *out, gint w, gint h);
+
+/**
+ * Mirrors a RS_RECT
+ * @param in A RS_RECT to read values from
+ * @param out A RS_RECT to write the values to (can be the same as in)
+ * @param w The width of the data OUTSIDE the RS_RECT
+ * @param h The height of the data OUTSIDE the RS_RECT
+ */
+extern void
+rs_rect_mirror(RS_RECT *in, RS_RECT *out, gint w, gint h);
+
+/**
+ * Rotate a RS_RECT in 90 degrees steps
+ * @param in A RS_RECT to read values from
+ * @param out A RS_RECT to write the values to (can be the same as in)
+ * @param w The width of the data OUTSIDE the RS_RECT
+ * @param h The height of the data OUTSIDE the RS_RECT
+ * @param quarterturns How many times to turn the rect clockwise
+ */
+extern void
+rs_rect_rotate(RS_RECT *in, RS_RECT *out, gint w, gint h, gint quarterturns);
+
#endif /* RS_UTILS_H */
More information about the Rawstudio-commit
mailing list