Photocam Widgets

The photocam widget displays high resolution photos taken from digital cameras. It provides a way to zoom in the photo, load it fast and fit it nicely. It is optimized for .jpeg images format and has a low memory footprint.

This widget implements the scroller interface, so all the functions concerning the scroller can be used with the photocam widget.

Table of Contents

Adding a Photocam

This is how to create a photocam widget and set an image file on it.

Evas_Object *photocam;
photocam = elm_photocam_add(win);
elm_photocam_file_set(photocam, "/tmp/photo.jpeg");

Using Photocam Zoom

We can choose between two automatic zoom modes and a manual zoom mode. Here we set the zoom mode to manual and ask for a double zoom.

elm_photocam_zoom_mode_set(photocam, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
elm_photocam_zoom_set(photocam, 2.0);

The zoom mode can be set to ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT. In this case, the photo fits exactly inside the scroll frame with no pixels outside this region. The zoom mode can also be set to ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL to fill all the pixels of the photocam widget.

Multi-touch zooming is activated by enabling gestures.

elm_photocam_gesture_enabled_set(photocam, EINA_TRUE);

We can zoom in a specific region. In this example, we want to zoom in the region starting at the coordinates (200×200), with a width of 400px and a height of 300px.

elm_photocam_image_region_bring_in(photocam, 200, 200, 400, 300);

Using Photocam Callbacks

The photocam widget emits the following signals:

  • “clicked” - This is called when a user has clicked the photo without dragging around.
  • “press” - This is called when a user has pressed down on the photo.
  • “longpressed” - This is called when a user has pressed down on the photo for a long time without dragging around.
  • “clicked,double” - This is called when a user has double-clicked the photo.
  • “load” - Photo load begins.
  • “loaded” - This is called when the image file load is complete for the first view (low resolution blurry version).
  • “load,detail” - Photo detailed data load begins.
  • “loaded,detail” - This is called when the image file load is complete for the detailed image data (full resolution needed).
  • “zoom,start” - Zoom animation started.
  • “zoom,stop” - Zoom animation stopped.
  • “zoom,change” - Zoom changed when using an auto zoom mode.
  • “scroll” - the content has been scrolled (moved)
  • “scroll,anim,start” - scrolling animation has started
  • “scroll,anim,stop” - scrolling animation has stopped
  • “scroll,drag,start” - dragging the contents around has started
  • “scroll,drag,stop” - dragging the contents around has stopped
  • “focused” - When the photocam has received focus. (since 1.8)
  • “unfocused” - When the photocam has lost focus. (since 1.8)

For all these signals, event_info is NULL.

This is how to register a callback on the “loaded” signal.

void message_port_cb(int local_port_id, const char *remote_app_id, bundle *message)
{
   evas_object_smart_callback_add(photocam, "loaded", _loaded_cb, data);
}
 
// Callback function for the "loaded" signal
// The photocam has loaded the photo file in a low resolution
 
static void
loaded_cb(void *data, Evas_Object *obj, void *event_info)
{
   printf("The photo has been loaded\n");
}


A Photocam Example