Photocam example

In this example we will have a photocam and a couple of buttons and slider to control the photocam. To avoid cluttering we'll only show the parts of the example that relate to the photocam, the full source code can be seen here.

Creating a photocam is as easy as creating any other widget:

photocam = elm_photocam_add(win);

A photocam is only useful if we have a image on it, so lets set a file for it to work with:

snprintf(buf, sizeof(buf), "%s/images/insanely_huge_test_image.jpg", elm_app_data_dir_get());
elm_photocam_file_set(photocam, buf);

We now set the photocam to not bounce horizontally:

And we want to know when the photocam has finished loading the image so:

evas_object_smart_callback_add(photocam, "loaded,detail", _bring_in, NULL);

The reason to know when the image is loaded is so that we can bring the center of the image into view:

static void
_bring_in(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
int w, h;
elm_photocam_image_region_bring_in(obj, w/2, h/2, 500, 400);
}

As mentioned we have 2 buttons in this example, the "Fit" one will cause the photocam to go in to a zoom mode that makes the image fit inside the photocam. Tough this has no effect on the image we also print what region was being viewed before setting the zoom mode:

static void
_fit(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
int x, y, w, h;
elm_photocam_image_region_get(data, &x, &y, &w, &h);
printf("region: {%d, %d, %d, %d}\n", x, y, w, h);
Note
When in fit mode our slider(explained below) won't work.

The second button("Unfit") will bring the photocam back into manual zoom mode:

static void
_unfit(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
}

Our slider controls the level of zoom of the photocam:

static void
_zoom(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
double z = elm_slider_value_get(obj) * 8;
}
Note
It is important to note that this only works when in manual zoom mode.

Our example will initially look like this:

elm_app_data_dir_get
const char * elm_app_data_dir_get(void)
Get the application's run time data prefix directory, as set by elm_app_info_set() and the way (envir...
Definition: elm_main.c:586
EINA_UNUSED
#define EINA_UNUSED
Used to indicate that a function parameter is purposely unused.
Definition: eina_types.h:339
EINA_FALSE
#define EINA_FALSE
boolean value FALSE (numerical value 0)
Definition: eina_types.h:533
elm_photocam_image_size_get
void elm_photocam_image_size_get(const Evas_Object *obj, int *w, int *h)
Get the current image pixel width and height.
Definition: efl_ui_image_zoomable.c:3363
evas_object_smart_callback_add
void evas_object_smart_callback_add(Evas_Object *eo_obj, const char *event, Evas_Smart_Cb func, const void *data)
Add (register) a callback function to the smart event specified by event on the smart object obj.
Definition: evas_object_smart.c:1040
elm_photocam_zoom_set
void elm_photocam_zoom_set(Evas_Object *obj, double zoom)
Set the zoom level of the photo.
Definition: efl_ui_image_zoomable.c:3384
Evas_Object
Efl_Canvas_Object Evas_Object
An Evas Object handle.
Definition: Evas_Common.h:185
elm_photocam_file_set
Evas_Load_Error elm_photocam_file_set(Evas_Object *obj, const char *file)
Set the photo file to be shown.
Definition: efl_ui_image_zoomable.c:3408
EINA_TRUE
#define EINA_TRUE
boolean value TRUE (numerical value 1)
Definition: eina_types.h:539
elm_photocam_add
Evas_Object * elm_photocam_add(Evas_Object *parent)
Add a new Photocam object.
Definition: efl_ui_image_zoomable.c:3290
elm_scroller_bounce_set
void elm_scroller_bounce_set(Evas_Object *obj, Eina_Bool h_bounce, Eina_Bool v_bounce)
Set bouncing behavior.
Definition: elm_scroller.c:1050
elm_photocam_zoom_mode_set
void elm_photocam_zoom_mode_set(Evas_Object *obj, Elm_Photocam_Zoom_Mode mode)
Set the zoom mode.
Definition: efl_ui_image_zoomable.c:3396
elm_slider_value_get
double elm_slider_value_get(const Evas_Object *obj)
Get the value displayed by the slider.
Definition: elm_slider.c:1531
elm_photocam_image_region_bring_in
void elm_photocam_image_region_bring_in(Evas_Object *obj, int x, int y, int w, int h)
Bring in the viewed portion of the image.
Definition: efl_ui_image_zoomable.c:3441