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.
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");
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);
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"); }