2 * @defgroup Image Image
5 * @image html image_inheritance_tree.png
6 * @image latex image_inheritance_tree.eps
8 * @image html img/widget/image/preview-00.png
9 * @image latex img/widget/image/preview-00.eps
11 * An Elementary image object is a direct realization of
12 * @ref elm-image-class, and it allows one to load and display an @b image
13 * file on it, be it from a disk file or from a memory
14 * region. Exceptionally, one may also load an Edje group as the
15 * contents of the image. In this case, though, most of the functions
16 * of the image API will act as a no-op.
18 * One can tune various properties of the image, like:
22 * - aspect ratio during resizes, etc.
24 * An image object may also be made valid source and destination for
25 * drag and drop actions, through the elm_image_editable_set() call.
27 * Signals that you can add callbacks for are:
29 * @li @c "drop" - This is called when a user has dropped an image
30 * typed object onto the object in question -- the
31 * event info argument is the path to that image file
32 * @li @c "clicked" - This is called when a user has clicked the image
34 * An example of usage for this API follows:
35 * @li @ref tutorial_image
44 * Possible orientation options for elm_image_orient_set().
46 * @image html elm_image_orient_set.png
47 * @image latex elm_image_orient_set.eps width=\textwidth
53 ELM_IMAGE_ORIENT_NONE = 0, /**< no orientation change */
54 ELM_IMAGE_ORIENT_0 = 0, /**< no orientation change */
55 ELM_IMAGE_ROTATE_90 = 1, /**< rotate 90 degrees clockwise */
56 ELM_IMAGE_ROTATE_180 = 2, /**< rotate 180 degrees clockwise */
57 ELM_IMAGE_ROTATE_270 = 3, /**< rotate 90 degrees counter-clockwise (i.e. 270 degrees clockwise) */
58 ELM_IMAGE_FLIP_HORIZONTAL = 4, /**< flip image horizontally */
59 ELM_IMAGE_FLIP_VERTICAL = 5, /**< flip image vertically */
60 ELM_IMAGE_FLIP_TRANSPOSE = 6, /**< flip the image along the y = (width - x) line (bottom-left to top-right) */
61 ELM_IMAGE_FLIP_TRANSVERSE = 7 /**< flip the image along the y = x line (top-left to bottom-right) */
65 * Add a new image to the parent.
67 * @param parent The parent object
68 * @return The new object or NULL if it cannot be created
70 * @see elm_image_file_set()
74 EAPI Evas_Object *elm_image_add(Evas_Object *parent);
77 * Set a location in memory to be used as an image object's source
80 * @param obj The image object
81 * @param img The binary data that will be used as image source
82 * @param size The size of binary data blob @p img
83 * @param format (Optional) expected format of @p img bytes
84 * @param key Optional indexing key of @p img to be passed to the
85 * image loader (eg. if @p img is a memory-mapped EET file)
87 * This function is handy when the contents of an image file are
88 * mapped in memory, for example.
90 * The @p format string should be something like @c "png", @c "jpg",
91 * @c "tga", @c "tiff", @c "bmp" etc, when provided (@c NULL, on the
92 * contrary). This improves the loader performance as it tries the
93 * "correct" loader first, before trying a range of other possible
94 * loaders until one succeeds.
96 * @return (@c EINA_TRUE = success, @c EINA_FALSE = error)
102 EAPI Eina_Bool elm_image_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key);
105 * Set the file that will be used as the image's source.
107 * @param obj The image object
108 * @param file The path to file that will be used as image source
109 * @param group The group that the image belongs to, in case it's an
110 * EET (including Edje case) file
112 * @return (@c EINA_TRUE = success, @c EINA_FALSE = error)
114 * @see elm_image_file_get()
116 * @note This function will trigger the Edje file case based on the
117 * extension of the @a file string (expects @c ".edj", for this
118 * case). If one wants to force this type of file independently of the
119 * extension, elm_image_file_edje_set() must be used, instead.
123 EAPI Eina_Bool elm_image_file_set(Evas_Object *obj, const char *file, const char *group);
126 * Get the file that will be used as image.
128 * @param obj The image object
129 * @param file The path to file
130 * @param group The group that the image belongs in edje file
132 * @see elm_image_file_set()
136 EAPI void elm_image_file_get(const Evas_Object *obj, const char **file, const char **group);
139 * Set the smooth effect for an image.
141 * @param obj The image object
142 * @param smooth @c EINA_TRUE if smooth scaling should be used, @c EINA_FALSE
143 * otherwise. Default is @c EINA_TRUE.
145 * Set the scaling algorithm to be used when scaling the image. Smooth
146 * scaling provides a better resulting image, but is slower.
148 * The smooth scaling should be disabled when making animations that change
149 * the image size, since it will be faster. Animations that don't require
150 * resizing of the image can keep the smooth scaling enabled (even if the
151 * image is already scaled, since the scaled image will be cached).
153 * @see elm_image_smooth_get()
157 EAPI void elm_image_smooth_set(Evas_Object *obj, Eina_Bool smooth);
160 * Get the smooth effect for an image.
162 * @param obj The image object
163 * @return @c EINA_TRUE if smooth scaling is enabled, @c EINA_FALSE otherwise.
165 * @see elm_image_smooth_get()
169 EAPI Eina_Bool elm_image_smooth_get(const Evas_Object *obj);
172 * Gets the current size of the image.
174 * @param obj The image object.
175 * @param w Pointer to store width, or NULL.
176 * @param h Pointer to store height, or NULL.
178 * This is the real size of the image, not the size of the object.
182 EAPI void elm_image_object_size_get(const Evas_Object *obj, int *w, int *h);
185 * Disable scaling of this object.
187 * @param obj The image object.
188 * @param no_scale @c EINA_TRUE if the object is not scalable, @c EINA_FALSE
189 * otherwise. Default is @c EINA_FALSE.
191 * This function disables scaling of the elm_image widget through the
192 * function elm_object_scale_set(). However, this does not affect the widget
193 * size/resize in any way. For that effect, take a look at
194 * elm_image_resizable_set().
196 * @see elm_image_no_scale_get()
197 * @see elm_image_resizable_set()
198 * @see elm_object_scale_set()
202 EAPI void elm_image_no_scale_set(Evas_Object *obj, Eina_Bool no_scale);
205 * Get whether scaling is disabled on the object.
207 * @param obj The image object
208 * @return @c EINA_TRUE if scaling is disabled, @c EINA_FALSE otherwise
210 * @see elm_image_no_scale_set()
214 EAPI Eina_Bool elm_image_no_scale_get(const Evas_Object *obj);
217 * Set if the object is (up/down) resizable.
219 * @param obj The image object
220 * @param size_up A bool to set if the object is resizable up. Default is
222 * @param size_down A bool to set if the object is resizable down. Default
225 * This function limits the image resize ability. If @p size_up is set to
226 * @c EINA_FALSE, the object can't have its height or width resized to a value
227 * higher than the original image size. Same is valid for @p size_down.
229 * @see elm_image_resizable_get()
233 EAPI void elm_image_resizable_set(Evas_Object *obj, Eina_Bool size_up, Eina_Bool size_down);
236 * Get if the object is (up/down) resizable.
238 * @param obj The image object
239 * @param size_up A bool to set if the object is resizable up
240 * @param size_down A bool to set if the object is resizable down
242 * @see elm_image_resizable_set()
246 EAPI void elm_image_resizable_get(const Evas_Object *obj, Eina_Bool *size_up, Eina_Bool *size_down);
249 * Set if the image fills the entire object area, when keeping the aspect ratio.
251 * @param obj The image object
252 * @param fill_outside @c EINA_TRUE if the object is filled outside,
253 * @c EINA_FALSE otherwise. Default is @c EINA_FALSE.
255 * When the image should keep its aspect ratio even if resized to another
256 * aspect ratio, there are two possibilities to resize it: keep the entire
257 * image inside the limits of height and width of the object (@p fill_outside
258 * is @c EINA_FALSE) or let the extra width or height go outside of the object,
259 * and the image will fill the entire object (@p fill_outside is @c EINA_TRUE).
261 * @note This option will have no effect if
262 * elm_image_aspect_fixed_set() is set to @c EINA_FALSE.
264 * @see elm_image_fill_outside_get()
265 * @see elm_image_aspect_fixed_set()
269 EAPI void elm_image_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside);
272 * Get if the object is filled outside
274 * @param obj The image object
275 * @return @c EINA_TRUE if the object is filled outside, @c EINA_FALSE otherwise.
277 * @see elm_image_fill_outside_set()
281 EAPI Eina_Bool elm_image_fill_outside_get(const Evas_Object *obj);
284 * Enable or disable preloading of the image
286 * @param obj The image object
287 * @param disabled If EINA_TRUE, preloading will be disabled
290 EAPI void elm_image_preload_disabled_set(Evas_Object *obj, Eina_Bool disabled);
293 * Set the prescale size for the image
295 * @param obj The image object
296 * @param size The prescale size. This value is used for both width and
299 * This function sets a new size for pixmap representation of the given
300 * image. It allows the image to be loaded already in the specified size,
301 * reducing the memory usage and load time when loading a big image with load
302 * size set to a smaller size.
304 * It's equivalent to the elm_bg_load_size_set() function for bg.
306 * @note this is just a hint, the real size of the pixmap may differ
307 * depending on the type of image being loaded, being bigger than requested.
309 * @see elm_image_prescale_get()
310 * @see elm_bg_load_size_set()
314 EAPI void elm_image_prescale_set(Evas_Object *obj, int size);
317 * Get the prescale size for the image
319 * @param obj The image object
320 * @return The prescale size
322 * @see elm_image_prescale_set()
326 EAPI int elm_image_prescale_get(const Evas_Object *obj);
329 * Set the image orientation.
331 * @param obj The image object
332 * @param orient The image orientation @ref Elm_Image_Orient
333 * Default is #ELM_IMAGE_ORIENT_NONE.
335 * This function allows to rotate or flip the given image.
337 * @see elm_image_orient_get()
338 * @see @ref Elm_Image_Orient
342 EAPI void elm_image_orient_set(Evas_Object *obj, Elm_Image_Orient orient);
345 * Get the image orientation.
347 * @param obj The image object
348 * @return The image orientation @ref Elm_Image_Orient
350 * @see elm_image_orient_set()
351 * @see @ref Elm_Image_Orient
355 EAPI Elm_Image_Orient elm_image_orient_get(const Evas_Object *obj);
358 * Make the image 'editable'.
360 * @param obj Image object.
361 * @param set Turn on or off editability. Default is @c EINA_FALSE.
363 * This means the image is a valid drag target for drag and drop, and can be
368 EAPI void elm_image_editable_set(Evas_Object *obj, Eina_Bool set);
371 * Check if the image is 'editable'.
373 * @param obj Image object.
374 * @return Editability.
376 * A return value of EINA_TRUE means the image is a valid drag target
377 * for drag and drop, and can be cut or pasted too.
381 EAPI Eina_Bool elm_image_editable_get(const Evas_Object *obj);
384 * Get the inlined image object of the image widget.
386 * @param obj The image object to get the inlined image from
387 * @return The inlined image object, or NULL if none exists
389 * This function allows one to get the underlying @c Evas_Object of type
390 * Image from this elementary widget. It can be useful to do things like get
391 * the pixel data, save the image to a file, etc.
393 * @note Be careful to not manipulate it, as it is under control of
398 EAPI Evas_Object *elm_image_object_get(const Evas_Object *obj);
401 * Set whether the original aspect ratio of the image should be kept on resize.
403 * @param obj The image object.
404 * @param fixed @c EINA_TRUE if the image should retain the aspect,
405 * @c EINA_FALSE otherwise.
407 * The original aspect ratio (width / height) of the image is usually
408 * distorted to match the object's size. Enabling this option will retain
409 * this original aspect, and the way that the image is fit into the object's
410 * area depends on the option set by elm_image_fill_outside_set().
412 * @see elm_image_aspect_fixed_get()
413 * @see elm_image_fill_outside_set()
417 EAPI void elm_image_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed);
420 * Get if the object retains the original aspect ratio.
422 * @param obj The image object.
423 * @return @c EINA_TRUE if the object keeps the original aspect, @c EINA_FALSE
428 EAPI Eina_Bool elm_image_aspect_fixed_get(const Evas_Object *obj);
431 * Get whether an image object supports animation or not.
433 * @param obj The image object
434 * @return @c EINA_TRUE if the image supports animation,
435 * @c EINA_FALSE otherwise.
437 * This function returns if this Elementary image object's internal
438 * image can be animated. Currently Evas only supports GIF
439 * animation. If the return value is @b EINA_FALSE, other
440 * @c elm_image_animated_xxx API calls won't work.
442 * @see elm_image_animated_set()
447 EAPI Eina_Bool elm_image_animated_available_get(const Evas_Object *obj);
450 * Set whether an image object (which supports animation) is to
451 * animate itself or not.
453 * @param obj The image object
455 * @param animated @c EINA_TRUE if the object is to animate itself,
456 * @c EINA_FALSE otherwise. Default is @c EINA_FALSE.
458 * An image object, even if it supports animation, will be displayed
459 * by default without animation. Call this function with @a animated
460 * set to @c EINA_TRUE to enable its animation. To start or stop the
461 * animation, actually, use elm_image_animated_play_set().
463 * @see elm_image_animated_get()
464 * @see elm_image_animated_available_get()
465 * @see elm_image_animated_play_set()
470 EAPI void elm_image_animated_set(Evas_Object *obj, Eina_Bool animated);
473 * Get whether an image object has animation enabled or not.
475 * @param obj The image object
477 * @return @c EINA_TRUE if the image has animation enabled,
478 * @c EINA_FALSE otherwise.
480 * @see elm_image_animated_set()
485 EAPI Eina_Bool elm_image_animated_get(const Evas_Object *obj);
488 * Start or stop an image object's animation.
490 * @param obj The image object
491 * @param play @c EINA_TRUE to start the animation, @c EINA_FALSE
492 * otherwise. Default is @c EINA_FALSE.
494 * To actually start playing any image object's animation, if it
495 * supports it, one must do something like:
498 * if (elm_image_animated_available_get(img))
500 * elm_image_animated_set(img, EINA_TRUE);
501 * elm_image_animated_play_set(img, EINA_TRUE);
505 * elm_image_animated_set() will enable animation on the image, <b>but
506 * not start it yet</b>. This is the function one uses to start and
507 * stop animations on image objects.
509 * @see elm_image_animated_available_get()
510 * @see elm_image_animated_set()
511 * @see elm_image_animated_play_get()
516 EAPI void elm_image_animated_play_set(Evas_Object *obj, Eina_Bool play);
519 * Get whether an image object is under animation or not.
521 * @param obj The image object
522 * @return @c EINA_TRUE, if the image is being animated, @c EINA_FALSE
525 * @see elm_image_animated_play_get()
530 EAPI Eina_Bool elm_image_animated_play_get(const Evas_Object *obj);