Here are grouped together functions used to create and manipulate image objects. More...
Typedefs | |
| typedef void(* | Evas_Object_Image_Pixels_Get_Cb )(void *data, Evas_Object *o) |
| typedef enum _Evas_Colorspace | Evas_Colorspace |
| Colorspaces for pixel data supported by Evas. More... | |
Enumerations | |
| enum | _Evas_Colorspace { EVAS_COLORSPACE_ARGB8888, EVAS_COLORSPACE_YCBCR422P601_PL, EVAS_COLORSPACE_YCBCR422P709_PL, EVAS_COLORSPACE_RGB565_A5P, EVAS_COLORSPACE_GRY8, EVAS_COLORSPACE_YCBCR422601_PL, EVAS_COLORSPACE_YCBCR420NV12601_PL, EVAS_COLORSPACE_YCBCR420TM12601_PL, EVAS_COLORSPACE_AGRY88, EVAS_COLORSPACE_ETC1, EVAS_COLORSPACE_RGB8_ETC2, EVAS_COLORSPACE_RGBA8_ETC2_EAC } |
| Colorspaces for pixel data supported by Evas. More... | |
Functions | |
| Eina_Bool | evas_object_image_extension_can_load_get (const char *file) |
| Check if a file extension may be supported by Image Object Functions. More... | |
| Eina_Bool | evas_object_image_extension_can_load_fast_get (const char *file) |
| Check if a file extension may be supported by Image Object Functions. More... | |
| Evas_Object * | evas_object_image_add (Evas *e) |
Creates a new image object on the given Evas e canvas. More... | |
| Evas_Object * | evas_object_image_filled_add (Evas *e) |
| Creates a new image object that automatically scales its bound image to the object's area, on both axis. More... | |
| void | evas_object_image_memfile_set (Evas_Object *obj, void *data, int size, char *format, char *key) |
| Sets the data for an image from memory to be loaded. More... | |
| void | evas_object_image_native_surface_set (Evas_Object *obj, Evas_Native_Surface *surf) |
| Set the native surface of a given image of the canvas. More... | |
| void | evas_object_image_preload (Evas_Object *obj, Eina_Bool cancel) |
| Preload an image object's image data in the background. More... | |
| Eina_Bool | evas_object_image_source_unset (Evas_Object *obj) |
| Clear the source object on a proxy image object. More... | |
| void | evas_object_image_alpha_mask_set (Evas_Object *obj, Eina_Bool ismask) |
| Enable an image to be used as an alpha mask. More... | |
Here are grouped together functions used to create and manipulate image objects.
They are available to whichever occasion one needs complex imagery on a GUI that could not be achieved by the other Evas' primitive object types, or to make image manipulations.
Evas will support whichever image file types it was compiled with support to (its image loaders) – check your software packager for that information and see evas_object_image_extension_can_load_get().
The most common use of image objects – to display an image on the canvas – is achieved by a common function triplet:
The first function, naturally, is creating the image object. Then, one must set an source file on it, so that it knows where to fetch image data from. Next, one must set how to fill the image object's area with that given pixel data. One could use just a sub-region of the original image or even have it tiled repeatedly on the image object. For the common case of having the whole source image to be displayed on the image object, stretched to the destination's size, there's also a function helper, to be used instead of evas_object_image_fill_set():
See those functions' documentation for more details.
Resizing of image objects will scale their respective source images to their areas, if they are set to "fill" the object's area (evas_object_image_filled_set()). If the user wants any control on the aspect ratio of an image for different sizes, he/she has to take care of that themselves. There are functions to make images to get loaded scaled (up or down) in memory, already, if the user is going to use them at pre-determined sizes and wants to save computations.
Evas has even a scale cache, which will take care of caching scaled versions of images with more often usage/hits. Finally, one can have images being rescaled smoothly by Evas (more computationally expensive) or not.
When dealing with image objects, there are some tricks to boost the performance of your application, if it does intense image loading and/or manipulations, as in animations on a UI.
In image viewer applications, for example, the user will be looking at a given image, at full size, and will desire that the navigation to the adjacent images on his/her album be fluid and fast. Thus, while displaying a given image, the program can be on the background loading the next and previous images already, so that displaying them on the sequence is just a matter of repainting the screen (and not decoding image data).
Evas addresses this issue with image pre-loading. The code for the situation above would be something like the following:
If you're loading images which are too big, consider setting previously it's loading size to something smaller, in case you won't expose them in real size. It may speed up the loading considerably:
Refer to Elementary's Photocam widget for a high level (smart) object which does lots of loading speed-ups for you.
If you want to animate image objects on a UI (what you'd get by concomitant usage of other libraries, like Ecore and Edje), there are also some tips on how to boost the performance of your application. If the animation involves resizing of an image (thus, re-scaling), you'd better turn off smooth scaling on it during the animation, turning it back on afterwards, for less computations. Also, in this case you'd better flag the image object in question not to cache scaled versions of it:
Finally, movement of opaque images through the canvas is less expensive than of translucid ones, because of blending computations.
Evas provides facilities for one to specify an image's region to be treated specially – as "borders". This will make those regions be treated specially on resizing scales, by keeping their aspect. This makes setting frames around other objects on UIs easy. See the following figures for a visual explanation:
Full-size
Full-size
Evas image objects can be used to manipulate raw pixels in many ways. The meaning of the data in the pixel arrays will depend on the image's color space, be warned (see next section). You can set your own data as an image's pixel data, fetch an image's pixel data for saving/altering, convert images between different color spaces and even advanced operations like setting a native surface as image objects' data.
Image objects may return or accept "image data" in multiple formats. This is based on the color space of an object. Here is a rundown on formats:
Some examples on this group of functions can be found here.
| typedef enum _Evas_Colorspace Evas_Colorspace |
Colorspaces for pixel data supported by Evas.
Colorspaces for pixel data supported by Evas
| enum _Evas_Colorspace |
Colorspaces for pixel data supported by Evas.
| Eina_Bool evas_object_image_extension_can_load_get | ( | const char * | file | ) |
Check if a file extension may be supported by Image Object Functions.
| file | The file to check |
EINA_TRUE if we may be able to open it, EINA_FALSE if it's unlikely. If file is a Eina_Stringshare, use directly evas_object_image_extension_can_load_fast_get.
This functions is threadsafe.
References eina_stringshare_add(), and eina_stringshare_del().
| Eina_Bool evas_object_image_extension_can_load_fast_get | ( | const char * | file | ) |
Check if a file extension may be supported by Image Object Functions.
| file | The file to check, it should be an Eina_Stringshare. |
EINA_TRUE if we may be able to open it, EINA_FALSE if it's unlikely. This functions is threadsafe.
| Evas_Object* evas_object_image_add | ( | Evas * | e | ) |
Creates a new image object on the given Evas e canvas.
| e | The given canvas. |
Example:
Referenced by ecore_evas_cursor_set(), ecore_evas_ews_new(), ecore_evas_object_image_new(), and evas_object_image_filled_add().
| Evas_Object* evas_object_image_filled_add | ( | Evas * | e | ) |
Creates a new image object that automatically scales its bound image to the object's area, on both axis.
| e | The given canvas. |
This is a helper function around evas_object_image_add() and evas_object_image_filled_set(). It has the same effect of applying those functions in sequence, which is a very common use case.
References evas_object_image_add().
| void evas_object_image_memfile_set | ( | Evas_Object * | obj, |
| void * | data, | ||
| int | size, | ||
| char * | format, | ||
| char * | key | ||
| ) |
Sets the data for an image from memory to be loaded.
This is the same as evas_object_image_file_set() but the file to be loaded may exist at an address in memory (the data for the file, not the filename itself). The data at the address is copied and stored for future use, so no data needs to be kept after this call is made. It will be managed and freed for you when no longer needed. The size is limited to 2 gigabytes in size, and must be greater than 0. A NULL data pointer is also invalid. Set the filename to NULL to reset to empty state and have the image file data freed from memory using evas_object_image_file_set().
The format is optional (pass NULL if you don't need/use it). It is used to help Evas guess better which loader to use for the data. It may simply be the "extension" of the file as it would normally be on disk such as "jpg" or "png" or "gif" etc.
| obj | The given image object. |
| data | The image file data address |
| size | The size of the image file data in bytes |
| format | The format of the file (optional), or NULL if not needed |
| key | The image key in file, or NULL. |
References eina_file_close(), eina_file_virtualize(), and EINA_TRUE.
| void evas_object_image_native_surface_set | ( | Evas_Object * | obj, |
| Evas_Native_Surface * | surf | ||
| ) |
Set the native surface of a given image of the canvas.
| obj | The given canvas pointer. |
| surf | The new native surface. |
This function sets a native surface of a given canvas image.
References EVAS_CALLBACK_DEL, evas_object_event_callback_add(), and evas_object_event_callback_del_full().
| void evas_object_image_preload | ( | Evas_Object * | obj, |
| Eina_Bool | cancel | ||
| ) |
Preload an image object's image data in the background.
| obj | The given image object. |
| cancel | EINA_FALSE will add it the preloading work queue, EINA_TRUE will remove it (if it was issued before). |
This function requests the preload of the data image in the background. The work is queued before being processed (because there might be other pending requests of this type).
Whenever the image data gets loaded, Evas will call EVAS_CALLBACK_IMAGE_PRELOADED registered callbacks on obj (what may be immediately, if the data was already preloaded before).
Use EINA_TRUE for cancel on scenarios where you don't need the image data preloaded anymore.
| Eina_Bool evas_object_image_source_unset | ( | Evas_Object * | obj | ) |
Clear the source object on a proxy image object.
| obj | Image object to clear source of. |
EINA_TRUE on success, EINA_FALSE on error.This is equivalent to calling evas_object_image_source_set() with a NULL source.
References EINA_FALSE.
| void evas_object_image_alpha_mask_set | ( | Evas_Object * | obj, |
| Eina_Bool | ismask | ||
| ) |
Enable an image to be used as an alpha mask.
This will set any flags, and discard any excess image data not used as an alpha mask.
Note there is little point in using a image as alpha mask unless it has an alpha channel.
| obj | Object to use as an alpha mask. |
| ismask | Use image as alphamask, must be true. |