Enlightenment CVS committal
Author : titan
Project : e17
Module : apps/ephoto
Dir : e17/apps/ephoto/src/bin
Modified Files:
ephoto.h ephoto_edit_view.c ephoto_imaging.c
Log Message:
Ephoto can now convert images to black and white. The filter is under
the
advanced tools in the edit view.
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- ephoto.h 19 May 2007 16:59:09 -0000 1.21
+++ ephoto.h 22 May 2007 23:04:02 -0000 1.22
@@ -85,6 +85,7 @@
unsigned int *rotate_right(Ewl_Widget *image);
unsigned int *blur_image(Ewl_Widget *image);
unsigned int *sharpen_image(Ewl_Widget *image);
+unsigned int *grayscale_image(Ewl_Widget *image);
void update_image(Ewl_Widget *image, int w, int h, unsigned int *data);
void save_dialog(const char *file);
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto_edit_view.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- ephoto_edit_view.c 14 May 2007 21:54:05 -0000 1.21
+++ ephoto_edit_view.c 22 May 2007 23:04:02 -0000 1.22
@@ -14,6 +14,7 @@
static void rotate_image_right(Ewl_Widget *w, void *event, void *data);
static void image_blur(Ewl_Widget *w, void *event, void *data);
static void image_sharpen(Ewl_Widget *w, void *event, void *data);
+static void image_grayscale(Ewl_Widget *w, void *event, void *data);
/*Add the edit view*/
Ewl_Widget *add_edit_view(Ewl_Widget *c)
@@ -139,6 +140,11 @@
ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
+ button = add_button(c, "Black and White", NULL, image_grayscale, NULL);
+ ewl_button_image_size_set(EWL_BUTTON(button), 30, 30);
+ ewl_object_alignment_set(EWL_OBJECT(button), EWL_FLAG_ALIGN_LEFT);
+ ewl_object_fill_policy_set(EWL_OBJECT(button), EWL_FLAG_FILL_HFILL);
+
return;
}
@@ -313,3 +319,16 @@
return;
}
+/*Convert image to Black and White*/
+static void image_grayscale(Ewl_Widget *w, void *event, void *data)
+{
+ unsigned int *image_data;
+ int nw, nh;
+
+ evas_object_image_size_get(EWL_IMAGE(em->eimage)->image, &nw, &nh);
+ image_data = grayscale_image(em->eimage);
+ update_image(em->eimage, nw, nh, image_data);
+ ewl_widget_configure(em->eimage->parent);
+
+ return;
+}
===================================================================
RCS file: /cvs/e/e17/apps/ephoto/src/bin/ephoto_imaging.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- ephoto_imaging.c 18 May 2007 21:47:24 -0000 1.11
+++ ephoto_imaging.c 22 May 2007 23:04:02 -0000 1.12
@@ -280,6 +280,30 @@
return im_data_new;
}
+unsigned int *grayscale_image(Ewl_Widget *image)
+{
+ unsigned int *im_data, *im_data_new;
+ int gray, i, r, g, b, a, ew, eh;
+
+ im_data = evas_object_image_data_get(EWL_IMAGE(image)->image, FALSE);
+ evas_object_image_size_get(EWL_IMAGE(image)->image, &ew, &eh);
+
+ im_data_new = malloc(sizeof(unsigned int) * ew * eh);
+
+ for (i = 0; i < (ew * eh); i++)
+ {
+ b = (int)((im_data[i]) & 0xff);
+ g = (int)((im_data[i] >> 8) & 0xff);
+ r = (int)((im_data[i] >> 16) & 0xff);
+ a = (int)((im_data[i] >> 24) & 0xff);
+
+ gray = (int)((0.3 * r) + (0.59 * g) + (0.11 * b));
+
+ im_data_new[i] = (gray << 24) | (gray << 16) | (gray << 8) |
gray;
+ }
+ return im_data_new;
+}
+
void update_image(Ewl_Widget *image, int w, int h, unsigned int *data)
{
if (w && h && !data)
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs