Elementary image widget

This code snippet shows how to create an elementary image widget.
//icon directory should look like this
#define ICON_DIR "/opt/usr/apps/org.example.myapp/res/images"

static void image_test(Evas_Object *parent) {
    //create an image
    Evas_Object *image = elm_image_add(parent);
    elm_win_resize_object_add(parent, image);
    
    //set it's source
    char path[100] = { 0 };
    snprintf(path, sizeof(path), ICON_DIR"/%s", "image.png");
    
    if (!elm_image_file_set(image, path, NULL)) {
    	dlog_print(DLOG_ERROR, LOG_TAG, "Unable to load image!");
    }
    
    //enable image drag&drop, cut&paste
    elm_image_editable_set(image, EINA_TRUE);
    
    //the image fills entire parent object
    elm_image_fill_outside_set(image, EINA_TRUE);
    
    evas_object_show(image);
}

Responses

0 Replies