emile: region_set does not working in jpeg loader if scale_down has set 43/87043/2
authorjiin.moon <jiin.moon@samsung.com>
Wed, 17 Aug 2016 07:39:13 +0000 (16:39 +0900)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Mon, 12 Sep 2016 07:28:59 +0000 (00:28 -0700)
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

Change-Id: Ie4df52f8858c014b5a243c79dbb5110d11d717be

src/lib/emile/emile_image.c

index c7d12b8..fc799ce 100644 (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)))
      {