Photocam bring in function

This code snippet shows how to use bring in function for photocam widget. In this sample a basic layout with a photocam and a button is created. Clicking the button brings in the top left corner area of the image.
//icon directory should look like this
#define IMG_DIR "/opt/usr/apps/org.example.myapp/res/images"

//this function brings in the beginning of the image (top left corner)
static void bring_in_cb(void *data, Evas_Object *obj, void *event_info) {
	Evas_Object *photocam = data;
	elm_photocam_image_region_bring_in(photocam, 0, 0, 50, 50);
	
	//similar effect but without animation
	//elm_photocam_image_region_show(photocam, 0, 0, 50, 50);
}

static void photocam_test(Evas_Object *parent) {
	//create a box for photocam and button
	Evas_Object *box = elm_box_add(parent);
	evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_win_resize_object_add(parent, box);
	evas_object_show(box);

	//create photocam
	Evas_Object *photocam = elm_photocam_add(parent);
	evas_object_size_hint_weight_set(photocam, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(photocam, EVAS_HINT_FILL, EVAS_HINT_FILL);
	elm_box_pack_end(box, photocam);

	char path[100] = { 0 };
	snprintf(path, sizeof(path), IMG_DIR"/%s", "big_image.jpg");
	elm_photocam_file_set(photocam, path);
	evas_object_show(photocam);

	//create button
	Evas_Object *btn = elm_button_add(parent);
	elm_object_text_set(btn, "Beginning");
	evas_object_show(btn);
	elm_box_pack_end(box, btn);

	//set callback
	evas_object_smart_callback_add(btn, "clicked", bring_in_cb, photocam);
}

Responses

0 Replies