In this example, we'll demonstrate the use of ecore_evas_object_image_new().
The idea is to have the same scene created for Ecore_Evas buffer example as the contents of an image object.
The canvas receiving this image object will have a white background, a red border image to delimit this image's boundaries and the image itself. After we create the special image, we set its "fill" property, place and resize it as we want. We have also to resize its underlying Ecore_Evas
too, to the same dimensions:
img, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6);
Now, we re-create the scene we cited, using the sub-canvas of our image to parent the objects in question. Because image objects are created with the alpha channel enabled, by default, we'll be seeing our white rectangle beneath the scene:
And that's all. The contents of our image could be updated as one wished, and they would always be mirrored in the image's area.
Check that destination file for the result. The full example follows.
#ifdef HAVE_CONFIG_H
#include "config.h"
#else
#define EINA_UNUSED
#define PACKAGE_EXAMPLES_DIR "."
#endif
#include <Ecore.h>
#include <stdio.h>
#define WIDTH (320)
#define HEIGHT (240)
static Ecore_Evas *ee;
static const char *border_img_path = PACKAGE_EXAMPLES_DIR "/red.png";
static void
{
}
int
main(void)
{
Evas *canvas, *sub_canvas;
Ecore_Evas *sub_ee;
if (!ee) goto error;
img, ((2 * WIDTH) / 3) - 6, ((2 * HEIGHT) / 3) - 6);
return 0;
error:
fprintf(stderr, "error: Requires at least one Evas engine built"
" and linked to ecore-evas for this example to run"
" properly.\n");
return -1;
}
EAPI Ecore_Evas * ecore_evas_new(const char *engine_name, int x, int y, int w, int h, const char *extra_options)
Creates a new Ecore_Evas based on engine name and common parameters.
Definition: ecore_evas.c:1065
Evas_Object * evas_object_image_filled_add(Evas *eo_e)
Creates a new image object that automatically scales its bound image to the object's area,...
Definition: evas_image_legacy.c:35
EAPI int ecore_evas_shutdown(void)
Shuts down the Ecore_Evas system.
Definition: ecore_evas.c:674
void evas_object_image_border_set(Evas_Object *obj, int l, int r, int t, int b)
Dimensions of this image's border, a region that does not scale with the center area.
Definition: evas_image_legacy.c:117
void evas_object_image_filled_set(Evas_Object *eo_obj, Eina_Bool value)
Set whether the image object's fill property should track the object's size.
Definition: evas_image_legacy.c:81
void ecore_main_loop_quit(void)
Quits the main loop once all the events currently on the queue have been processed.
Definition: ecore_main.c:1300
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition: eina_types.h:339
EAPI void ecore_evas_free(Ecore_Evas *ee)
Frees an Ecore_Evas.
Definition: ecore_evas.c:1109
EAPI void ecore_evas_title_set(Ecore_Evas *ee, const char *t)
Sets the title of an Ecore_Evas' window.
Definition: ecore_evas.c:1553
EAPI int ecore_evas_init(void)
Inits the Ecore_Evas system.
Definition: ecore_evas.c:606
EAPI Evas * ecore_evas_object_evas_get(Evas_Object *obj)
Retrieve the canvas bound to the internal Ecore_Evas handle of an image object created via ecore_evas...
Definition: ecore_evas.c:1146
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition: Evas_Common.h:180
void evas_object_image_border_center_fill_set(Evas_Object *obj, Evas_Border_Fill_Mode fill)
Specifies how the center part of the object (not the borders) should be drawn when EFL is rendering i...
Definition: evas_image_legacy.c:145
EAPI void ecore_evas_callback_delete_request_set(Ecore_Evas *ee, Ecore_Evas_Event_Cb func)
Sets a callback for Ecore_Evas delete request events.
Definition: ecore_evas.c:1202
void evas_object_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
Changes the size of the given Evas object.
Definition: evas_object_main.c:1236
void evas_object_image_size_set(Evas_Object *eo_obj, int w, int h)
Sets the size of the given image object.
Definition: evas_image_legacy.c:847
EAPI Evas * ecore_evas_get(const Ecore_Evas *ee)
Gets an Ecore_Evas's Evas.
Definition: ecore_evas.c:1326
void ecore_main_loop_begin(void)
Runs the application main loop.
Definition: ecore_main.c:1290
EAPI void ecore_evas_size_min_set(Ecore_Evas *ee, int w, int h)
Sets the minimum size of a given Ecore_Evas window.
Definition: ecore_evas.c:1586
void evas_object_show(Evas_Object *eo_obj)
Makes the given Evas object visible.
Definition: evas_object_main.c:1814
Eo Evas
An opaque handle to an Evas canvas.
Definition: Evas_Common.h:158
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition: eina_types.h:539
EAPI Ecore_Evas * ecore_evas_object_ecore_evas_get(Evas_Object *obj)
Retrieve the internal Ecore_Evas handle of an image object created via ecore_evas_object_image_new().
Definition: ecore_evas.c:1157
void evas_object_image_file_set(Evas_Object *obj, const char *file, const char *key)
Set the source file from where an image object must fetch the real image data (it may be an Eet file,...
Definition: evas_image_legacy.c:194
EAPI void ecore_evas_resize(Ecore_Evas *ee, int w, int h)
Resizes an Ecore_Evas.
Definition: ecore_evas.c:1350
Evas_Object * evas_object_rectangle_add(Evas *e)
Adds a rectangle to the given evas.
Definition: evas_object_rectangle.c:78
EAPI void ecore_evas_size_max_set(Ecore_Evas *ee, int w, int h)
Sets the maximum size of a given Ecore_Evas window.
Definition: ecore_evas.c:1622
EAPI Evas_Object * ecore_evas_object_image_new(Ecore_Evas *ee_target)
Creates an Evas image object with image data bound to an own, internal Ecore_Evas canvas wrapper
Definition: ecore_evas_buffer.c:942
void evas_object_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
Move the given Evas object to the given location inside its canvas' viewport.
Definition: evas_object_main.c:1171
@ EVAS_BORDER_FILL_NONE
Image's center region is not to be rendered.
Definition: Evas_Legacy.h:5708
EAPI void ecore_evas_show(Ecore_Evas *ee)
Shows an Ecore_Evas' window.
Definition: ecore_evas.c:1506
void evas_object_color_set(Evas_Object *obj, int r, int g, int b, int a)
Sets the general/main color of the given Evas object to the given one.
Definition: evas_object_main.c:2024