Resizing image widgets

This code snippet shows some of the functions that can be used to properly resize elementary image object.
#define ICON_DIR "/opt/usr/apps/org.example.myapp/res/images"

static void image_test(Evas_Object *parent) {
	Evas_Object *image = elm_image_add(parent);
	elm_win_resize_object_add(parent, image);

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

	//disable scalingh through elm_object_scale_set() (and only by this function)
	elm_image_no_scale_set(image, EINA_TRUE);

	//disable resizing (here image can't be scaled up (second param), but can be scaled down (third param)
	elm_image_resizable_set(image, EINA_FALSE, EINA_TRUE);

	//use smooth scaling (it's better, but slower)
	elm_image_smooth_set(image, EINA_TRUE);

	//rotate image by 180 degrees (different rotate and flip options available)
	elm_image_orient_set(image, ELM_IMAGE_ROTATE_180);

	//keep original aspect ratio
	elm_image_aspect_fixed_set(image, EINA_TRUE);

	evas_object_show(image);
}

Responses

0 Replies