Try to fix png crash issue 48/144548/1
authorxinyan.mei <xinyan.mei@samsung.com>
Fri, 11 Aug 2017 09:37:29 +0000 (17:37 +0800)
committerVictor Cebollada <v.cebollada@samsung.com>
Thu, 17 Aug 2017 06:21:33 +0000 (07:21 +0100)
Problem: png crash
Reason: png header info indicate that color type is RGB  width = 92, height = 92.
        but real rowbytes is 92 x 4, it means the color type should be RGBA
Solution: Correct the pixelformat according to the real rowbytes

Change-Id: I90f2865b54c62da6fdb41f32abe3971e274b6e94
Signed-off-by: xinyan.mei <xinyan.mei@samsung.com>
platform-abstractions/tizen/image-loaders/loader-png.cpp [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index e6fdcde..89bca77
@@ -299,7 +299,20 @@ bool LoadBitmapFromPng( const ImageLoader::Input& input, Integration::Bitmap& bi
   if( rowBytes > stride )
   {
     stride = GetTextureDimension(rowBytes);
-    bufferWidth = stride / bpp;
+
+    bpp = stride / bufferWidth;
+    switch(bpp)
+    {
+      case 3:
+        pixelFormat = Pixel::RGB888;
+        break;
+      case 4:
+        pixelFormat = Pixel::RGBA8888;
+        break;
+      default:
+        break;
+    }
+
   }
 
   // decode the whole image into bitmap buffer