Enlightenment CVS committal
Author : dj2
Project : e17
Module : libs/ewl
Dir : e17/libs/ewl/src/lib
Modified Files:
ewl_enums.h ewl_image.c ewl_image.h
Log Message:
- add rephorms image rotation and flip code to ewl. you can now do things
like ewl_image_flip(img, EWL_ORIENTATION_HORIZONTAL) or
ewl_image_rotate(img, EWL_ROTATE_CW_90)
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_enums.h,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -3 -r1.56 -r1.57
--- ewl_enums.h 26 Sep 2006 18:33:47 -0000 1.56
+++ ewl_enums.h 10 Oct 2006 21:32:16 -0000 1.57
@@ -721,6 +721,24 @@
typedef enum Ewl_Text_Wrap Ewl_Text_Wrap;
/**
+ * @enum Ewl_Rotate
+ * The rotate values
+ */
+enum Ewl_Rotate
+{
+ EWL_ROTATE_CW_90,
+ EWL_ROTATE_180,
+ EWL_ROTATE_CW_270,
+ EWL_ROTATE_CC_90,
+ EWL_ROTATE_CC_270
+};
+
+/**
+ * The Ewl_Rotate
+ */
+typedef enum Ewl_Rotate Ewl_Rotate;
+
+/**
* @}
*/
#endif /* __EWL_ENUMS_H__ */
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_image.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -3 -r1.49 -r1.50
--- ewl_image.c 9 Oct 2006 06:21:17 -0000 1.49
+++ ewl_image.c 10 Oct 2006 21:32:16 -0000 1.50
@@ -15,6 +15,9 @@
static Ewl_Image_Type ewl_image_type_get(const char *i);
static void ewl_image_thumbnail_cb_destroy(Ewl_Widget *w, void *ev, void
*data);
+static void ewl_image_rotate_180(Ewl_Image *img);
+static void ewl_image_rotate_90(Ewl_Image *img, int cc);
+
/**
* @return Returns a pointer to a new image widget on success, NULL on failure.
* @brief Load an image widget with specified image contents
@@ -475,6 +478,97 @@
}
/**
+ * @param img: The image to flip
+ * @param orient: The orientation to flip
+ * @return Returns no value
+ * @brief Flips the given image in the given direction
+ */
+void
+ewl_image_flip(Ewl_Image *img, Ewl_Orientation orient)
+{
+ int ix, iy, ox, oy, mx, my, i, j, w, h;
+ int *ia, *ib, *oa, *ob, s;
+ unsigned int *in;
+ unsigned int tmp;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("img", img);
+ DCHECK_TYPE("img", img, EWL_IMAGE_TYPE);
+
+ evas_object_image_size_get(img->image, &w, &h);
+ in = evas_object_image_data_get(img->image, TRUE);
+
+ if (orient == EWL_ORIENTATION_VERTICAL)
+ {
+ mx = w;
+ my = h / 2;
+ ia = &iy;
+ ib = &ix;
+ oa = &oy;
+ ob = &ox;
+ s = h;
+ }
+ else
+ {
+ mx = w / 2;
+ my = h;
+ ia = &ix;
+ ib = &iy;
+ oa = &ox;
+ ob = &oy;
+ s = w;
+ }
+
+ for (iy = 0; iy < my; iy++)
+ {
+ for (ix = 0; ix < mx; ix++)
+ {
+ *oa = s - 1 - *ia;
+ *ob = *ib;
+
+ i = iy * w + ix;
+ j = oy * w + ox;
+
+ tmp = in[j];
+ in[j] = in[i];
+ in[i] = tmp;
+ }
+ }
+
+ evas_object_image_data_set(img->image, in);
+ evas_object_image_data_update_add(img->image, 0, 0, w, h);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
+ * @param i: The image to rotate
+ * @param rotate: The amount to rotate the image
+ * @return Returns no value
+ * @brief Rotates the given image by the given @a rotate value
+ */
+void
+ewl_image_rotate(Ewl_Image *i, Ewl_Rotate rotate)
+{
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("i", i);
+ DCHECK_TYPE("i", i, EWL_IMAGE_TYPE);
+
+ if (rotate == EWL_ROTATE_180)
+ ewl_image_rotate_180(i);
+
+ else if ((rotate == EWL_ROTATE_CW_90) ||
+ (rotate == EWL_ROTATE_CC_270))
+ ewl_image_rotate_90(i, FALSE);
+
+ else
+ ewl_image_rotate_90(i, TRUE);
+
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
* @param i: the image to thumbnail
* @return Returns a thumbnailed image widget on success, NULL on failure.
* @brief Create a widget representing a thumbnailed version of the image.
@@ -1017,6 +1111,103 @@
evas_event_feed_mouse_move(emb->evas, ev->x, ev->y,
(unsigned int)((unsigned long
long)(ecore_time_get() * 1000.0) & 0xffffffff),
NULL);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+static void
+ewl_image_rotate_90(Ewl_Image *img, int cc)
+{
+ int i, j, w = 0, h = 0, ix, iy, ox, oy, os, ow, oh;
+ int *ia, *ib, *oa, *ob;
+ unsigned int *in, *out;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("img", img);
+ DCHECK_TYPE("img", img, EWL_IMAGE_TYPE);
+
+ evas_object_image_size_get(img->image, &w, &h);
+ in = evas_object_image_data_get(img->image, FALSE);
+
+ out = malloc(w * h * sizeof(unsigned int));
+
+ ow = h;
+ oh = w;
+
+ /* these pointers pull the invarient conditional out of the loop */
+ if (cc)
+ {
+ oa = &oy;
+ ob = &ox;
+ ia = &iy;
+ ib = &ix;
+ os = oh;
+ }
+ else
+ {
+ oa = &ox;
+ ob = &oy;
+ ia = &ix;
+ ib = &iy;
+ os = ow;
+ }
+
+ for (i = 0; i < (w * h); i++)
+ {
+ ix = i % w;
+ iy = i / w;
+
+ /* rotate */
+ *oa = os - 1 - *ib;
+ *ob = *ia;
+
+ /* convert back to array index */
+ j = oy * ow + ox;
+
+ out[j] = in[i];
+ }
+
+ img->ow = ow;
+ img->oh = oh;
+
+ evas_object_image_size_set(img->image, ow, oh);
+ evas_object_image_data_set(img->image, out);
+ evas_object_image_data_update_add(img->image, 0, 0, ow, oh);
+
+ ewl_object_preferred_inner_size_set(EWL_OBJECT(img), ow, oh);
+
+ DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+static void
+ewl_image_rotate_180(Ewl_Image *img)
+{
+ int ix, iy, ox, oy, i, j, size, w, h;
+ unsigned int *in, tmp;
+
+ DENTER_FUNCTION(DLEVEL_STABLE);
+ DCHECK_PARAM_PTR("img", img);
+ DCHECK_TYPE("img", img, EWL_IMAGE_TYPE);
+
+ evas_object_image_size_get(img->image, &w, &h);
+ in = evas_object_image_data_get(img->image, TRUE);
+
+ size = w * h / 2;
+ for (i = 0; i < size; i++)
+ {
+ ix = i % w;
+ iy = i / w;
+ ox = w - 1 - ix;
+ oy = h - 1 - iy;
+ j = oy * w + ox;
+
+ tmp = in[j];
+ in[j] = in[i];
+ in[i] = tmp;
+ }
+
+ evas_object_image_data_set(img->image, in);
+ evas_object_image_data_update_add(img->image, 0, 0, w, h);
DLEAVE_FUNCTION(DLEVEL_STABLE);
}
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_image.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -3 -r1.27 -r1.28
--- ewl_image.h 30 Sep 2006 18:41:01 -0000 1.27
+++ ewl_image.h 10 Oct 2006 21:32:16 -0000 1.28
@@ -122,6 +122,9 @@
void ewl_image_constrain_set(Ewl_Image *i, unsigned int size);
unsigned int ewl_image_constrain_get(Ewl_Image *i);
+void ewl_image_flip(Ewl_Image *img, Ewl_Orientation orient);
+void ewl_image_rotate(Ewl_Image *i, Ewl_Rotate rotate);
+
Ewl_Widget *ewl_image_thumbnail_get(Ewl_Image *i);
Ewl_Widget *ewl_image_thumbnail_new(void);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs