[Pkg-e-commits] [SCM] Enlightenment DR17 advanced canvas library branch, upstream-vcs, updated. ac02ff30b5a2960085b8e2a374ed135250be5ebc

raster raster at alioth.debian.org
Tue May 20 12:44:11 UTC 2008


The following commit has been merged in the upstream-vcs branch:
commit 8a854a7ba95bfbd4e8ca391a792728bfa6494e36
Author: raster <raster>
Date:   Mon May 19 03:13:16 2008 +0000

    colorspace stuff in cvs.

diff --git a/src/lib/Evas.h b/src/lib/Evas.h
index c3c59a2..93a1c00 100644
--- a/src/lib/Evas.h
+++ b/src/lib/Evas.h
@@ -532,6 +532,7 @@ extern "C" {
    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);
diff --git a/src/lib/canvas/evas_object_image.c b/src/lib/canvas/evas_object_image.c
index d6d25ad..de34734 100644
--- a/src/lib/canvas/evas_object_image.c
+++ b/src/lib/canvas/evas_object_image.c
@@ -67,6 +67,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) */
@@ -706,6 +708,46 @@ evas_object_image_load_error_get(const 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
@@ -1127,7 +1169,19 @@ evas_object_image_save(const Evas_Object *obj, const char *file, const char *key
                                             EVAS_COLORSPACE_ARGB8888);
    if (im)
      {
-        ok = evas_common_save_image_to_file(im, file, key, quality, compress);
+	if (o->cur.cspace == EVAS_COLORSPACE_ARGB8888)
+	  im->image.data = data;
+	else
+	  im->image.data = evas_object_image_data_convert_internal(o,
+								   data,
+								   EVAS_COLORSPACE_ARGB8888);
+	if (im->image.data)
+	  {
+	     ok = evas_common_save_image_to_file(im, file, key, quality, compress);
+
+	     if (o->cur.cspace != EVAS_COLORSPACE_ARGB8888)
+	       free(im->image.data);
+	  }
 
 	evas_cache_image_drop(&im->cache_entry);
      }
@@ -2373,3 +2427,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)
+     {
+	case EVAS_COLORSPACE_ARGB8888:
+	  out = evas_common_convert_argb8888_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,
+						  o->cur.image.h,
+						  o->cur.image.stride,
+						  o->cur.has_alpha,
+						  to_cspace);
+	  break;
+	default:
+	  break;
+     }
+
+   return out;
+}
diff --git a/src/lib/engines/common/Makefile.am b/src/lib/engines/common/Makefile.am
index a0e92d3..eff9edb 100644
--- a/src/lib/engines/common/Makefile.am
+++ b/src/lib/engines/common/Makefile.am
@@ -24,6 +24,7 @@ evas_op_mul_main_.c \
 evas_blend_main.c \
 evas_blit_main.c \
 evas_convert_color.c \
+evas_convert_colorspace.c \
 evas_convert_gry_1.c \
 evas_convert_gry_4.c \
 evas_convert_gry_8.c \
diff --git a/src/lib/include/evas_common.h b/src/lib/include/evas_common.h
index 273ab28..0ac6d68 100644
--- a/src/lib/include/evas_common.h
+++ b/src/lib/include/evas_common.h
@@ -1039,6 +1039,9 @@ EAPI void evas_common_convert_color_rgb_to_hsv                     (int r, int g
 EAPI void evas_common_convert_color_hsv_to_rgb_int                 (int h, int s, int v, int *r, int *g, int *b);
 EAPI void evas_common_convert_color_rgb_to_hsv_int                 (int r, int g, int b, int *h, int *s, int *v);
 
+EAPI void *evas_common_convert_argb8888_to                         (void *data, int w, int h, int stride, Evas_Bool has_alpha, Evas_Colorspace cspace);
+EAPI void *evas_common_convert_rgb565_a5p_to                       (void *data, int w, int h, int stride, Evas_Bool has_alpha, Evas_Colorspace cspace);
+
 /****/
 EAPI void evas_common_scale_init                            (void);
 

-- 
Enlightenment DR17 advanced canvas library



More information about the Pkg-e-commits mailing list