evas: add evas_object_image_load_orientation_set, evas_object_image_load_orientation_get.

SVN revision: 60040
This commit is contained in:
Cedric BAIL 2011-06-07 13:39:13 +00:00
parent 1e62ad24a3
commit 260718c700
8 changed files with 70 additions and 6 deletions

View File

@ -397,3 +397,5 @@
2011-06-07 Cedric Bail
* Use Eina_File for JPEG loader.
* Add evas_object_image_load_orientation_get and evas_object_image_load_orientation_set,
that tell if we should honor the orientation information when loading image file.

View File

@ -990,7 +990,7 @@ message(void *fdata __UNUSED__, Server *s __UNUSED__, Client *c, int opcode, int
Op_Load *rep;
Op_Load_Reply msg;
Img *img;
RGBA_Image_Loadopts lopt = {0, 0.0, 0, 0, {0, 0, 0, 0}};
RGBA_Image_Loadopts lopt = {0, 0.0, 0, 0, {0, 0, 0, 0}, 0};
char *file = NULL, *key = NULL;
DBG("OP_LOAD %i", c->pid);

View File

@ -5071,7 +5071,7 @@ EAPI void evas_object_image_load_size_set (Evas_Obj
/**
* Get the size of a loaded image of the canvas.
*
* @param obj The given canvas object.
* @param obj The given image object.
* @param w The width of the canvas image given.
* @param h The height of the canvas image given.
*
@ -5083,7 +5083,7 @@ EAPI void evas_object_image_load_size_get (const Ev
/**
* Set the scale down of a loaded image of the canvas.
*
* @param obj The given canvas pointer.
* @param obj The given image object pointer.
* @param scale_down The scale to down value.
*
* This function sets the scale down of a given canvas image.
@ -5103,6 +5103,23 @@ EAPI int evas_object_image_load_scale_down_get (const Ev
EAPI void evas_object_image_load_region_set (Evas_Object *obj, int x, int y, int w, int h) EINA_ARG_NONNULL(1);
EAPI void evas_object_image_load_region_get (const Evas_Object *obj, int *x, int *y, int *w, int *h) EINA_ARG_NONNULL(1);
/**
* Define if the orientation information in the image file should be honored.
*
* @param obj The given image object pointer.
* @param enable @p EINA_TRUE means that it should honor the orientation information
* @since 1.1
*/
EAPI void evas_object_image_load_orientation_set (Evas_Object *obj, Eina_Bool enable) EINA_ARG_NONNULL(1);
/**
* Get if the orientation information in the image file should be honored.
*
* @param obj The given image object pointer.
* @since 1.1
*/
EAPI Eina_Bool evas_object_image_load_orientation_get (const Evas_Object *obj) EINA_ARG_NONNULL(1);
/**
* Set the colorspace of a given image of the canvas.
*

View File

@ -680,7 +680,7 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file,
const char *ckey = "(null)";
char *hkey;
Image_Entry *im;
Evas_Image_Load_Opts prevent = { 0, 0, 0, 0, { 0, 0, 0, 0 } };
Evas_Image_Load_Opts prevent = { 0, 0, 0, 0, { 0, 0, 0, 0 }, 0 };
size_t size;
int stat_done = 0, stat_failed = 0;
size_t file_length;
@ -697,7 +697,7 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file,
/* generate hkey from file+key+load opts */
file_length = strlen(file);
key_length = key ? strlen(key) : 6;
size = file_length + key_length + 128;
size = file_length + key_length + 132;
hkey = alloca(sizeof (char) * size);
memcpy(hkey, file, file_length);
size = file_length;
@ -711,7 +711,8 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file,
(lo->scale_down_by == 0) &&
(lo->dpi == 0.0) &&
((lo->w == 0) || (lo->h == 0)) &&
((lo->region.w == 0) || (lo->region.h == 0))
((lo->region.w == 0) || (lo->region.h == 0)) &&
(lo->orientation == 0)
))
{
lo = &prevent;
@ -742,6 +743,13 @@ evas_cache_image_request(Evas_Cache_Image *cache, const char *file,
hkey[size] = 'x';
size += 1;
size += eina_convert_xtoa(lo->region.h, hkey + size);
if (lo->orientation)
{
hkey[size] = '/';
hkey[size] = 'o';
size += 2;
}
}
hkey[size] = '\0';

View File

@ -56,6 +56,7 @@ struct _Evas_Object_Image
struct {
short x, y, w, h;
} region;
Eina_Bool orientation : 1;
} load_opts;
struct {
@ -315,6 +316,7 @@ evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key)
lo.region.y = o->load_opts.region.y;
lo.region.w = o->load_opts.region.w;
lo.region.h = o->load_opts.region.h;
lo.orientation = o->load_opts.orientation;
o->engine_data = obj->layer->evas->engine.func->image_load(obj->layer->evas->engine.data.output,
o->cur.file,
o->cur.key,
@ -1609,6 +1611,36 @@ evas_object_image_load_region_get(const Evas_Object *obj, int *x, int *y, int *w
if (h) *h = o->load_opts.region.h;
}
EAPI void
evas_object_image_load_orientation_set(Evas_Object *obj, Eina_Bool enable)
{
Evas_Object_Image *o;
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
o = (Evas_Object_Image *)(obj->object_data);
MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
return;
MAGIC_CHECK_END();
o->load_opts.orientation = !!enable;
}
EAPI Eina_Bool
evas_object_image_load_orientation_get(const Evas_Object *obj)
{
Evas_Object_Image *o;
MAGIC_CHECK(obj, Evas_Object, MAGIC_OBJ);
return;
MAGIC_CHECK_END();
o = (Evas_Object_Image *)(obj->object_data);
MAGIC_CHECK(o, Evas_Object_Image, MAGIC_OBJ_IMAGE);
return;
MAGIC_CHECK_END();
return o->load_opts.orientation;
}
EAPI void
evas_object_image_colorspace_set(Evas_Object *obj, Evas_Colorspace cspace)
{
@ -2285,6 +2317,7 @@ evas_object_image_load(Evas_Object *obj)
lo.region.y = o->load_opts.region.y;
lo.region.w = o->load_opts.region.w;
lo.region.h = o->load_opts.region.h;
lo.orientation = o->load_opts.orientation;
o->engine_data = obj->layer->evas->engine.func->image_load
(obj->layer->evas->engine.data.output,
o->cur.file,

View File

@ -137,6 +137,7 @@ typedef struct
struct {
int x, y, w, h;
} region;
Eina_Bool orientation;
} lopt;
} Op_Load; // +"file""key"
typedef struct

View File

@ -302,6 +302,7 @@ evas_cserve_image_load(Image_Entry *ie, const char *file, const char *key, RGBA_
msg.lopt.region.y = lopt->region.y;
msg.lopt.region.w = lopt->region.w;
msg.lopt.region.h = lopt->region.h;
msg.lopt.orientation = lopt->orientation;
if (file[0] != '/')
{
if (getcwd(wdb, sizeof(wdb)))

View File

@ -488,6 +488,8 @@ struct _RGBA_Image_Loadopts
struct {
unsigned int x, y, w, h;
} region;
Eina_Bool orientation; // if EINA_TRUE => should honor orientation information provided by file (like jpeg exif info)
};
struct _Image_Entry_Flags