summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHermet Park <chuneon.park@samsung.com>2020-10-05 12:56:03 +0900
committerHermet Park <chuneon.park@samsung.com>2020-10-05 12:56:03 +0900
commitb6a98bb3be03dde89d633670a6eef298733885e8 (patch)
tree98b7fd539aeed210a68c73fcc5f9f9144ae1678a
parent42c123d1d7b4b5fa1251b3ae7768912f480d36a3 (diff)
downloadefl-b6a98bb3be03dde89d633670a6eef298733885e8.tar.gz
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
-rw-r--r--src/lib/elementary/efl_ui_image_zoomable.c34
1 files 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 689555180a..fb05a56115 100644
--- a/src/lib/elementary/efl_ui_image_zoomable.c
+++ b/src/lib/elementary/efl_ui_image_zoomable.c
@@ -2080,6 +2080,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)
{
@@ -2087,8 +2119,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;