[UI Sample] Image Sample Overview
The Image sample demonstrates how to display an image on the canvas using EFL image object functions. In addition, it moves and resizes an image.
The sample uses image object functions, such as evas_object_image_filled_add() and evas_object_image_file_set(), for adding an image to the given Evas. It also uses basic object manipulation functions, such as evas_object_move() and evas_object_resize(), for moving and changing the size of an image.
The following figure illustrates the main screen of Image.
Figure: Image screen
Implementation
The create_base_gui() function creates the window which consists of an image (Evas object) added using the evas_object_image_filled_add() function.
It also moves the image to the given x, y coordination inside its canvas viewport using the evas_object_move() function, and changes the size of the image using the evas_object_resize() function.
static void create_base_gui(appdata_s *ad) { // Window ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE); elm_win_autodel_set(ad->win, EINA_TRUE); if (elm_win_wm_rotation_supported_get(ad->win)) { int rots[4] = { 0, 90, 180, 270 }; elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4); } evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL); eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad); // Conformant ad->conform = elm_conformant_add(ad->win); elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW); elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE); evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(ad->win, ad->conform); evas_object_show(ad->conform); // Image Evas_Object *img; char img_path[PATH_MAX] = { 0, }; app_get_resource("tizen_logo.png", img_path, PATH_MAX); Evas* canvas = evas_object_evas_get(ad->conform); img = evas_object_image_filled_add(canvas); // Add an image to the given Evas evas_object_image_file_set(img, img_path, NULL); // Set the source file from where an image object must fetch the real image data evas_object_move(img, 50, 50); // Move the given Evas object to the given location inside its canvas viewport evas_object_resize(img, 300, 200); // Change the size of the given Evas object evas_object_show(img); // Make the given Evas object visible // Show the window after the base GUI is set up evas_object_show(ad->win); }