Re: [E-devel] Evas_Object_Image data colorspace convert

2008-05-19 Thread Andre Magalhaes
On Mon, May 19, 2008 at 12:03 AM, The Rasterman Carsten Haitzler
[EMAIL PROTECTED] wrote:
 On Tue, 6 May 2008 18:03:43 -0300 Andre Magalhaes [EMAIL PROTECTED]
 babbled:

 in cvs :)
I could have done it, but great thanks :)

-- 
Andre Moreira Magalhaes (andrunko)

Jabber: [EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]
Skype: andrunko
Blog: http://andrunko.blogspot.com

-
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


Re: [E-devel] Evas_Object_Image data colorspace convert

2008-05-18 Thread The Rasterman
On Tue, 6 May 2008 18:03:43 -0300 Andre Magalhaes [EMAIL PROTECTED]
babbled:

in cvs :)

 Hi again,
 
 I just tried and the patch didn't apply, so here is the update patch
 against CVS HEAD
 
 BR
 
 -- 
 Andre Moreira Magalhaes (andrunko)
 
 Jabber: [EMAIL PROTECTED]
 MSN: [EMAIL PROTECTED]
 Skype: andrunko
 Blog: http://andrunko.blogspot.com
 


-- 
- Codito, ergo sum - I code, therefore I am --
The Rasterman (Carsten Haitzler)[EMAIL PROTECTED]


-
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel


[E-devel] Evas_Object_Image data colorspace convert

2008-05-06 Thread Andre Magalhaes
Hi,

I have a patch to Evas_Object_Image that's here for a long time.
We even release our evas with this patch, but I never found the time
to finish it (needs conversion to from YUV colorspaces).
The main idea of the patch is to enable images with colorspace != 
to be saved to a file. It adds a method evas_object_image_data_convert
that can be really useful in other cases.

If you want I can commit it, tell me what you think

BR

Ps.: The patch is generated against a really old evas, but I believe
it still applies :)

-- 
Andre Moreira Magalhaes (andrunko)

Jabber: [EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]
Skype: andrunko
Blog: http://andrunko.blogspot.com
diff --git a/src/lib/Evas.h b/src/lib/Evas.h
index 18864ce..a56fd92 100644
--- a/src/lib/Evas.h
+++ b/src/lib/Evas.h
@@ -478,6 +478,7 @@ extern C {
EAPI void  evas_object_image_size_get(Evas_Object *obj, int *w, int *h);
EAPI int   evas_object_image_stride_get  (Evas_Object *obj);
EAPI int   evas_object_image_load_error_get  (Evas_Object *obj);
+   EAPI void *evas_object_image_data_convert(Evas_Object *obj, Evas_Colorspace to_cspace);
EAPI void  evas_object_image_data_set(Evas_Object *obj, void *data);
EAPI void *evas_object_image_data_get(Evas_Object *obj, Evas_Bool for_writing);
EAPI void  evas_object_image_data_copy_set   (Evas_Object *obj, void *data);
diff --git a/src/lib/canvas/evas_object_image.c b/src/lib/canvas/evas_object_image.c
index 6a8df55..92b0651 100644
--- a/src/lib/canvas/evas_object_image.c
+++ b/src/lib/canvas/evas_object_image.c
@@ -69,6 +69,8 @@ static int evas_object_image_is_opaque(Evas_Object *obj);
 static int evas_object_image_was_opaque(Evas_Object *obj);
 static int evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
 
+static void *evas_object_image_data_convert_internal(Evas_Object_Image *o, void *data, Evas_Colorspace to_cspace);
+
 static const Evas_Object_Func object_func =
 {
/* methods (compulsory) */
@@ -708,6 +710,46 @@ evas_object_image_load_error_get(Evas_Object *obj)
  */
 
 /**
+ * Converts the raw image data of the given image object to the
+ * specified colorspace.
+ *
+ * Note that this function does not modify the raw image data.
+ * If the requested colorspace is the same as the image colorspace
+ * nothing is done and NULL is returned. You should use
+ * evas_object_image_colorspace_get() to check the current image
+ * colorspace.
+ *
+ * See @ref evas_object_image_colorspace_get.
+ *
+ * @param obj The given image object.
+ * @param to_cspace The colorspace to which the image raw data will be converted.
+ * @return data A newly allocated data in the format specified by to_cspace.
+ * @ingroup Evas_Object_Image_Data
+ */
+EAPI void *
+evas_object_image_data_convert(Evas_Object *obj, Evas_Colorspace to_cspace)
+{
+   Evas_Object_Image *o;
+   DATA32 *data;
+
+   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+   return NULL;
+   MAGIC_CHECK_END();
+   o = (Evas_Object_Image *)(obj-object_data);
+   MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
+   return NULL;
+   MAGIC_CHECK_END();
+   if (!o-engine_data) return NULL;
+   if (!o-cur.cspace == to_cspace) return NULL;
+   data = NULL;
+   o-engine_data = obj-layer-evas-engine.func-image_data_get(obj-layer-evas-engine.data.output,
+  o-engine_data,
+  0,
+  data);
+   return evas_object_image_data_convert_internal(o, data, to_cspace);
+}
+
+/**
  * Sets the raw image data of the given image object.
  *
  * Note that the raw data must be of the same size and colorspace
@@ -1126,11 +1168,22 @@ evas_object_image_save(Evas_Object *obj, const char *file, const char *key, cons
  {
 	if (o-cur.has_alpha) im-flags |= RGBA_IMAGE_HAS_ALPHA;
 
-im-image-data = data;
-im-image-w = o-cur.image.w;
-im-image-h = o-cur.image.h;
-im-image-no_free = 1;
-ok = evas_common_save_image_to_file(im, file, key, quality, compress);
+	if (o-cur.cspace == EVAS_COLORSPACE_ARGB)
+	  im-image-data = data;
+	else
+	  im-image-data = evas_object_image_data_convert_internal(o,
+data,
+EVAS_COLORSPACE_ARGB);
+	if (im-image-data)
+	  {
+	 im-image-w = o-cur.image.w;
+	 im-image-h = o-cur.image.h;
+	 im-image-no_free = 1;
+	 ok = evas_common_save_image_to_file(im, file, key, quality, compress);
+
+	 if (o-cur.cspace != EVAS_COLORSPACE_ARGB)
+	   free(im-image-data);
+	  }
 
 	evas_cache_image_drop(im);
  }
@@ -2376,3 +2429,36 @@ evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
 
return (a != 0);
 }
+
+static void *
+evas_object_image_data_convert_internal(Evas_Object_Image *o, void *data, Evas_Colorspace to_cspace)
+{
+   void *out = NULL;
+
+   if (!data)
+ return NULL;
+
+   switch (o-cur.cspace)
+ {
+	

Re: [E-devel] Evas_Object_Image data colorspace convert

2008-05-06 Thread Andre Magalhaes
Hi again,

I just tried and the patch didn't apply, so here is the update patch
against CVS HEAD

BR

-- 
Andre Moreira Magalhaes (andrunko)

Jabber: [EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]
Skype: andrunko
Blog: http://andrunko.blogspot.com
? src/lib/engines/common/evas_convert_colorspace.c
? src/modules/engines/software_16_wince/.deps
? src/modules/engines/software_16_wince/Makefile
? src/modules/engines/software_16_wince/Makefile.in
Index: src/lib/Evas.h
===
RCS file: /cvs/e/e17/libs/evas/src/lib/Evas.h,v
retrieving revision 1.122
diff -u -r1.122 Evas.h
--- src/lib/Evas.h	1 May 2008 06:39:26 -	1.122
+++ src/lib/Evas.h	6 May 2008 20:58:02 -
@@ -532,6 +532,7 @@
EAPI int   evas_object_image_stride_get  (const Evas_Object *obj);
EAPI int   evas_object_image_load_error_get  (const Evas_Object *obj);
EAPI void  evas_object_image_data_set(Evas_Object *obj, void *data);
+   EAPI void *evas_object_image_data_convert(Evas_Object *obj, Evas_Colorspace to_cspace);
EAPI void *evas_object_image_data_get(const Evas_Object *obj, Evas_Bool for_writing);
EAPI void  evas_object_image_data_copy_set   (Evas_Object *obj, void *data);
EAPI void  evas_object_image_data_update_add (Evas_Object *obj, int x, int y, int w, int h);
Index: src/lib/canvas/evas_object_image.c
===
RCS file: /cvs/e/e17/libs/evas/src/lib/canvas/evas_object_image.c,v
retrieving revision 1.63
diff -u -r1.63 evas_object_image.c
--- src/lib/canvas/evas_object_image.c	1 May 2008 00:09:39 -	1.63
+++ src/lib/canvas/evas_object_image.c	6 May 2008 20:58:02 -
@@ -67,6 +67,8 @@
 static int evas_object_image_was_opaque(Evas_Object *obj);
 static int evas_object_image_is_inside(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
 
+static void *evas_object_image_data_convert_internal(Evas_Object_Image *o, void *data, Evas_Colorspace to_cspace);
+
 static const Evas_Object_Func object_func =
 {
/* methods (compulsory) */
@@ -706,6 +708,46 @@
  */
 
 /**
+ * Converts the raw image data of the given image object to the
+ * specified colorspace.
+ *
+ * Note that this function does not modify the raw image data.
+ * If the requested colorspace is the same as the image colorspace
+ * nothing is done and NULL is returned. You should use
+ * evas_object_image_colorspace_get() to check the current image
+ * colorspace.
+ *
+ * See @ref evas_object_image_colorspace_get.
+ *
+ * @param obj The given image object.
+ * @param to_cspace The colorspace to which the image raw data will be converted.
+ * @return data A newly allocated data in the format specified by to_cspace.
+ * @ingroup Evas_Object_Image_Data
+ */
+EAPI void *
+evas_object_image_data_convert(Evas_Object *obj, Evas_Colorspace to_cspace)
+{
+   Evas_Object_Image *o;
+   DATA32 *data;
+
+   MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
+   return NULL;
+   MAGIC_CHECK_END();
+   o = (Evas_Object_Image *)(obj-object_data);
+   MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
+   return NULL;
+   MAGIC_CHECK_END();
+   if (!o-engine_data) return NULL;
+   if (!o-cur.cspace == to_cspace) return NULL;
+   data = NULL;
+   o-engine_data = obj-layer-evas-engine.func-image_data_get(obj-layer-evas-engine.data.output,
+  o-engine_data,
+  0,
+  data);
+   return evas_object_image_data_convert_internal(o, data, to_cspace);
+}
+
+/**
  * Sets the raw image data of the given image object.
  *
  * Note that the raw data must be of the same size and colorspace
@@ -1127,7 +1169,19 @@
 EVAS_COLORSPACE_ARGB);
if (im)
  {
-ok = evas_common_save_image_to_file(im, file, key, quality, compress);
+	if (o-cur.cspace == EVAS_COLORSPACE_ARGB)
+	  im-image.data = data;
+	else
+	  im-image.data = evas_object_image_data_convert_internal(o,
+   data,
+   EVAS_COLORSPACE_ARGB);
+	if (im-image.data)
+	  {
+	 ok = evas_common_save_image_to_file(im, file, key, quality, compress);
+
+	 if (o-cur.cspace != EVAS_COLORSPACE_ARGB)
+	   free(im-image.data);
+	  }
 
 	evas_cache_image_drop(im-cache_entry);
  }
@@ -2372,4 +2426,37 @@
  }
 
return (a != 0);
+}
+
+static void *
+evas_object_image_data_convert_internal(Evas_Object_Image *o, void *data, Evas_Colorspace to_cspace)
+{
+   void *out = NULL;
+
+   if (!data)
+ return NULL;
+
+   switch (o-cur.cspace)
+ {
+	case EVAS_COLORSPACE_ARGB:
+	  out = evas_common_convert_argb_to(data,
+		o-cur.image.w,
+		o-cur.image.h,
+		o-cur.image.stride,
+		o-cur.has_alpha,
+		to_cspace);
+	  break;
+	case EVAS_COLORSPACE_RGB565_A5P:
+	  out = evas_common_convert_rgb565_a5p_to(data,
+		  o-cur.image.w,
+