Fix for incorrect error code checking in JPEG header loading
[platform/core/uifw/dali-adaptor.git] / platform-abstractions / slp / resource-loader / loader-jpeg-turbo.cpp
index d8cd9a1..f3084f9 100755 (executable)
@@ -786,30 +786,36 @@ bool LoadJpegHeader(FILE *fp, const ImageAttributes& attributes, unsigned int &w
     // Double check we get the same width/height from the header
     unsigned int headerWidth;
     unsigned int headerHeight;
-    LoadJpegHeader( fp, headerWidth, headerHeight );
-
-    JPGFORM_CODE transform = JPGFORM_NONE;
-
-    if( attributes.GetOrientationCorrection() )
+    if( LoadJpegHeader( fp, headerWidth, headerHeight ) )
     {
-      ExifAutoPtr exifData( LoadExifData( fp ) );
-      if( exifData.mData )
+      JPGFORM_CODE transform = JPGFORM_NONE;
+
+      if( attributes.GetOrientationCorrection() )
       {
-        transform = ConvertExifOrientation(exifData.mData);
-      }
+        ExifAutoPtr exifData( LoadExifData( fp ) );
+        if( exifData.mData )
+        {
+          transform = ConvertExifOrientation(exifData.mData);
+        }
 
-      int preXformImageWidth = headerWidth;
-      int preXformImageHeight = headerHeight;
-      int postXformImageWidth = headerWidth;
-      int postXformImageHeight = headerHeight;
+        int preXformImageWidth = headerWidth;
+        int preXformImageHeight = headerHeight;
+        int postXformImageWidth = headerWidth;
+        int postXformImageHeight = headerHeight;
 
-      success = TransformSize(requiredWidth, requiredHeight, transform, preXformImageWidth, preXformImageHeight, postXformImageWidth, postXformImageHeight);
-      if(success)
+        success = TransformSize(requiredWidth, requiredHeight, transform, preXformImageWidth, preXformImageHeight, postXformImageWidth, postXformImageHeight);
+        if(success)
+        {
+          width = postXformImageWidth;
+          height = postXformImageHeight;
+        }
+      }
+      else
       {
-        width = postXformImageWidth;
-        height = postXformImageHeight;
+        success = true;
+        width = headerWidth;
+        height = headerHeight;
       }
-      success = true;
     }
   }
   return success;