Tizen(Headed) Native API  6.5
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:

   elm_scroller_bounce_set(photocam, EINA_FALSE, EINA_TRUE);

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_size_get(obj, &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;
   elm_photocam_zoom_set(data, z);
}

Note:
It is important to note that this only works when in manual zoom mode.