2 //gcc -o photocam_example_01 photocam_example_01.c -g `pkg-config --cflags --libs elementary` -DDATA_DIR="\"<directory>\""
3 //where directory is the path where images/insanely_huge_test_image.jpg can be found.
5 #include <Elementary.h>
7 static void _fit(void *data, Evas_Object *obj, void *event_info);
8 static void _unfit(void *data, Evas_Object *obj, void *event_info);
9 static void _zoom(void *data, Evas_Object *obj, void *event_info);
10 static void _bring_in(void *data, Evas_Object *obj, void *event_info);
13 elm_main(int argc, char **argv)
15 Evas_Object *win, *bg, *obj, *photocam;
18 elm_app_info_set(elm_main, "elementary", "images/insanely_huge_test_image.jpg");
19 win = elm_win_add(NULL, "photocam", ELM_WIN_BASIC);
20 elm_win_title_set(win, "Photocam");
21 elm_win_autodel_set(win, EINA_TRUE);
22 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
25 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
26 elm_win_resize_object_add(win, bg);
29 photocam = elm_photocam_add(win);
30 snprintf(buf, sizeof(buf), "%s/images/insanely_huge_test_image.jpg", elm_app_data_dir_get());
31 elm_photocam_file_set(photocam, buf);
32 elm_photocam_bounce_set(photocam, EINA_FALSE, EINA_TRUE);
33 evas_object_smart_callback_add(photocam, "loaded,detail", _bring_in, NULL);
34 evas_object_resize(photocam, 500, 400);
35 evas_object_show(photocam);
37 obj = elm_button_add(win);
38 elm_object_text_set(obj, "Fit");
39 evas_object_show(obj);
40 evas_object_resize(obj, 50, 30);
41 evas_object_move(obj, 10, 410);
42 evas_object_smart_callback_add(obj, "clicked", _fit, photocam);
44 obj = elm_button_add(win);
45 elm_object_text_set(obj, "Unfit");
46 evas_object_show(obj);
47 evas_object_resize(obj, 70, 30);
48 evas_object_move(obj, 70, 410);
49 evas_object_smart_callback_add(obj, "clicked", _unfit, photocam);
51 obj = elm_slider_add(win);
52 elm_object_text_set(obj, "Zoom");
53 evas_object_show(obj);
54 evas_object_resize(obj, 300, 30);
55 evas_object_move(obj, 150, 410);
56 evas_object_smart_callback_add(obj, "changed", _zoom, photocam);
58 evas_object_resize(win, 500, 440);
59 evas_object_show(win);
69 _bring_in(void *data, Evas_Object *obj, void *event_info)
72 elm_photocam_image_size_get(obj, &w, &h);
73 elm_photocam_image_region_bring_in(obj, w/2, h/2, 500, 400);
77 _fit(void *data, Evas_Object *obj, void *event_info)
80 elm_photocam_image_region_get(data, &x, &y, &w, &h);
81 printf("region: {%d, %d, %d, %d}\n", x, y, w, h);
82 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT);
86 _unfit(void *data, Evas_Object *obj, void *event_info)
88 elm_photocam_zoom_mode_set(data, ELM_PHOTOCAM_ZOOM_MODE_MANUAL);
92 _zoom(void *data, Evas_Object *obj, void *event_info)
94 double z = elm_slider_value_get(obj) * 8;
95 elm_photocam_zoom_set(data, z);