From fecbcf8a905e30345d3454c9cdb665a6d7b098bc Mon Sep 17 00:00:00 2001 From: "jiin.moon" Date: Wed, 17 Aug 2016 16:39:13 +0900 Subject: [PATCH] emile: region_set does not working in jpeg loader if scale_down has set Summary: If both region and scale_down has set, ERR would be returned by loader of jpeg. @fix Test Plan: sample code Reviewers: raster, jypark, cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4200 --- src/lib/emile/emile_image.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/lib/emile/emile_image.c b/src/lib/emile/emile_image.c index 5bad68c..5c12035 100644 --- a/src/lib/emile/emile_image.c +++ b/src/lib/emile/emile_image.c @@ -1724,11 +1724,6 @@ _emile_jpeg_data(Emile_Image *image, { region = 1; - opts_region.x = opts->region.x; - opts_region.y = opts->region.y; - opts_region.w = opts->region.w; - opts_region.h = opts->region.h; - if (prop->rotated) { unsigned int load_region_x = 0, load_region_y = 0; @@ -1738,19 +1733,31 @@ _emile_jpeg_data(Emile_Image *image, load_region_y = opts->region.y; load_region_w = opts->region.w; load_region_h = opts->region.h; - _rotate_region(&opts_region.x, &opts_region.y, &opts_region.w, &opts_region.h, load_region_x, load_region_y, load_region_w, load_region_h, w, h, degree, prop->flipped); } -#ifdef BUILD_LOADER_JPEG_REGION - cinfo.region_x = opts_region.x; - cinfo.region_y = opts_region.y; - cinfo.region_w = opts_region.w; - cinfo.region_h = opts_region.h; -#endif + + /* scale value already applied when decompress. + When access to decoded image, have to apply scale value to region value */ + if (prop->scale > 1) + { + opts_region.x = opts->region.x / prop->scale; + opts_region.y = opts->region.y / prop->scale; + opts_region.w = opts->region.w / prop->scale; + opts_region.h = opts->region.h / prop->scale; + + } + else + { + opts_region.x = opts->region.x; + opts_region.y = opts->region.y; + opts_region.w = opts->region.w; + opts_region.h = opts->region.h; + } + } if ((!region) && ((w != ie_w) || (h != ie_h))) { -- 2.7.4