edje: Edje_Edit - add new feature edje_edit_image_compression_set.
authorMaksym Volodin <m.volodin@samsung.com>
Tue, 3 Jun 2014 22:38:27 +0000 (00:38 +0200)
committerCedric BAIL <c.bail@partner.samsung.com>
Tue, 3 Jun 2014 22:51:56 +0000 (00:51 +0200)
Summary:
Set compression type for the given image. Has object being edited,
the name of the image and Edje_Edit_Image_Comp(EDJE_EDIT_IMAGE_COMP_RAW,
EDJE_EDIT_IMAGE_COMP_USER, EDJE_EDIT_IMAGE_COMP_COMP,
EDJE_EDIT_IMAGE_COMP_LOSSY[_ETC1]) as in parametrs.
Return EINA_TRUE if successful, EINA_FALSE - otherwise.

Reviewers: cedric, raster, seoz, Hermet

Reviewed By: cedric

CC: reutskiy.v.v, cedric
Differential Revision: https://phab.enlightenment.org/D929

Signed-off-by: Cedric BAIL <c.bail@partner.samsung.com>
src/lib/edje/Edje_Edit.h
src/lib/edje/edje_edit.c

index 1838e94ee9a1b7cf859b312170d732ef2cc467f1..83145fe3880bd7d4dc104dd10c77c0181540d0b7 100644 (file)
@@ -2991,6 +2991,17 @@ EAPI int edje_edit_image_id_get(Evas_Object *obj, const char *image_name);
  */
 EAPI Edje_Edit_Image_Comp edje_edit_image_compression_type_get(Evas_Object *obj, const char *image);
 
+/** Set compression type for the given image.
+ *
+ * @param obj Object being edited.
+ * @param image The name of the image.
+ * @param ic Edje_Edit_Image_Comp.
+ * (EDJE_EDIT_IMAGE_COMP_RAW, EDJE_EDIT_IMAGE_COMP_USER, EDJE_EDIT_IMAGE_COMP_COMP, EDJE_EDIT_IMAGE_COMP_LOSSY[_ETC1]).
+ *
+ * @return EINA_TRUE if successful, EINA_FALSE - otherwise.
+ */
+EAPI Eina_Bool edje_edit_image_compression_type_set(Evas_Object *obj, const char *image, Edje_Edit_Image_Comp ic);
+
 /** Get compression rate for the given image.
  *
  * @param obj Object being edited.
index 5e97bb7e52df5f5241fbcc3870dad9bbc8964434..2ab1373488e5e569ab3293a563207bed5955213d 100644 (file)
@@ -5341,6 +5341,63 @@ edje_edit_image_compression_type_get(Evas_Object *obj, const char *image)
    return -1;
 }
 
+EAPI Eina_Bool
+edje_edit_image_compression_type_set(Evas_Object *obj, const char *image, Edje_Edit_Image_Comp ic)
+{
+   Edje_Image_Directory_Entry *de = NULL;
+   unsigned int i;
+
+   GET_ED_OR_RETURN(EINA_FALSE);
+
+   if (!ed->file) return EINA_FALSE;
+   if (!ed->file->image_dir) return EINA_FALSE;
+
+   for (i = 0; i < ed->file->image_dir->entries_count; ++i)
+     {
+        de = ed->file->image_dir->entries + i;
+        if ((de->entry) && (!strcmp(image, de->entry)))
+          break;
+     }
+
+   if (i == ed->file->image_dir->entries_count) return EINA_FALSE;
+
+   switch(ic)
+     {
+      case EDJE_EDIT_IMAGE_COMP_RAW: // RAW
+        if (de->source_param == 0)
+          {
+             de->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT;
+             return EINA_TRUE;
+          }
+        else
+          return EINA_FALSE;
+      case EDJE_EDIT_IMAGE_COMP_COMP: // COMP
+        if (de->source_param == 1)
+          {
+             de->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_PERFECT;
+             return EINA_TRUE;
+          }
+        else
+          return EINA_FALSE;
+      case EDJE_EDIT_IMAGE_COMP_LOSSY: // LOSSY
+          {
+             de->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY;
+             return EINA_TRUE;
+          }
+      case EDJE_EDIT_IMAGE_COMP_LOSSY_ETC1: // LOSSY_ETC1
+          {
+             de->source_type = EDJE_IMAGE_SOURCE_TYPE_INLINE_LOSSY_ETC1;
+             return EINA_TRUE;
+          }
+      case EDJE_EDIT_IMAGE_COMP_USER: // USER
+          {
+             de->source_type = EDJE_IMAGE_SOURCE_TYPE_EXTERNAL;
+             return EINA_TRUE;
+          }
+     }
+   return EINA_FALSE;
+}
+
 EAPI int
 edje_edit_image_compression_rate_get(Evas_Object *obj, const char *image)
 {