Fixed Png type tranparent problem of RGB565 decoding
authorJungYumin <y_m.jung@samsung.com>
Tue, 25 Jun 2013 03:48:31 +0000 (12:48 +0900)
committerJungYumin <y_m.jung@samsung.com>
Tue, 25 Jun 2013 07:11:47 +0000 (16:11 +0900)
Change-Id: I36d584ed4f89235e672b97ffee2217356484e8d6
Signed-off-by: JungYumin <y_m.jung@samsung.com>
src/FMedia_ImageDecoder.cpp
src/FMedia_ImageUtil.cpp
src/inc/FMedia_ImageUtil.h

index f2118cb..8aba056 100644 (file)
@@ -410,6 +410,10 @@ _ImageDecoder::DecodeN(int& outLength, ImageScalingMethod scalingMethod)
                                                  __pixelFormat, __outDim.width, __outDim.height, scalingMethod);
                SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated.", GetErrorMessage(r));
 
+               if (__pDec->GetPixelFormat() == MEDIA_PIXEL_FORMAT_BGRA8888 && __pixelFormat == MEDIA_PIXEL_FORMAT_RGB565LE)
+               {
+                       _ImageUtil::PremultiplyAlpha(pRawBuf.get(), rawLength, MEDIA_PIXEL_FORMAT_BGRA8888);
+               }
                // Convert to output format
                pOutBuf.reset(cvt.ConvertN(pRawBuf.get(), rawLength, outLength));
                r = GetLastResult();
index e790e6f..f8c0061 100644 (file)
@@ -2931,4 +2931,18 @@ _ImageUtil::GetResizedDimension(int srcWidth, int srcHeight, float dstWidth, flo
        return E_SUCCESS;
 }
 
+result
+_ImageUtil::PremultiplyAlpha(byte* data, int length, MediaPixelFormat pixelFormat)
+{
+       unsigned int *pPixel = (unsigned int*)data;
+       for (int i = 0; i < length / 4; i++)
+       {
+               unsigned int a = 1 + (*pPixel >> 24);
+               *pPixel = (*pPixel & 0xff000000) +
+                                 (((((*pPixel) >> 8) & 0xff) * a) & 0xff00) +
+                                 (((((*pPixel) & 0x00ff00ff) * a) >> 8) & 0x00ff00ff);
+               pPixel++;
+       }
+}
+
 }} // Tizen::Media
index e06e1c2..ebd731b 100644 (file)
@@ -155,6 +155,9 @@ public:
                                                                          float dstWidth, float dstHeight,
                                                                          float &outWidth, float &outHeight);
 
+
+       static result PremultiplyAlpha(byte* data, int length, MediaPixelFormat pixelFormat);
+
 private:
        _ImageUtil();