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
This commit is contained in:
jiin.moon 2016-08-17 16:39:13 +09:00 committed by Jean-Philippe Andre
parent 3bdefaf31f
commit fecbcf8a90
1 changed files with 19 additions and 12 deletions

View File

@ -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)))
{