From 2213131f68182072749e99d90bd60bcc908d14c6 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 5 Oct 2020 12:56:03 +0900 Subject: [PATCH] elementary image zoomable: fix non supported oversized image. Summary: if image size is larger than system support, photocam can not show the image. Not like other types of image, photocam is originally designed for huge-size of image, this result is not allowed by users, we should avoid the worst case as we can do. This might not be the best idea, so you can improve it if you have a better solution. Reviewers: kimcinoo Reviewed By: kimcinoo Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12164 Change-Id: I6e542227062dae8d42fd870d1e6a69a935df5d12 --- src/lib/elementary/efl_ui_image_zoomable.c | 34 ++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/lib/elementary/efl_ui_image_zoomable.c b/src/lib/elementary/efl_ui_image_zoomable.c index 64d38c3..dbb5bee 100644 --- a/src/lib/elementary/efl_ui_image_zoomable.c +++ b/src/lib/elementary/efl_ui_image_zoomable.c @@ -2093,6 +2093,38 @@ _internal_file_set(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd, Evas_Load_Error *ret evas_object_image_file_set(sd->img, NULL, NULL); evas_object_image_load_scale_down_set(sd->img, 0); _photocam_image_file_set(sd->img, sd); + + //Check whether image size is bigger than maxium texture + evas_object_image_size_get(sd->img, &w, &h); + int maxw = 0, maxh = 0; + evas_image_max_size_get(evas_object_evas_get(sd->img), &maxw, &maxh); + + /* Image is too large than system support, + This case it won't be available, + Alternatively, reduce size by half and make it visible at least. + Btw, is this the best solution for this?... */ + if (maxw > 0 && maxh > 0) + { + int w2 = w; + int h2 = h; + + if (w2 > maxw || h2 > maxh) + { + //Scale down by half + int scale_down = 1; + + while (w2 > maxw || h2 > maxh) + { + w2 /= 2; + h2 /= 2; + scale_down *= 2; + } + + //This might not work at some format... + evas_object_image_load_scale_down_set(sd->img, scale_down); + } + } + err = evas_object_image_load_error_get(sd->img); if (err != EVAS_LOAD_ERROR_NONE) { @@ -2100,8 +2132,6 @@ _internal_file_set(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd, Evas_Load_Error *ret if (ret) *ret = err; return err; } - evas_object_image_size_get(sd->img, &w, &h); - sd->do_region = evas_object_image_region_support_get(sd->img); sd->size.imw = w; sd->size.imh = h; -- 2.7.4