Fixed transparent issue of RGB565
authorJungYumin <y_m.jung@samsung.com>
Thu, 20 Jun 2013 06:05:58 +0000 (15:05 +0900)
committerJungYumin <y_m.jung@samsung.com>
Thu, 20 Jun 2013 06:05:58 +0000 (15:05 +0900)
Change-Id: I688ca07fe95eee5c644dea133ab3bb686f12ec3e
Signed-off-by: JungYumin <y_m.jung@samsung.com>
src/FMedia_GifDecoderImpl.cpp
src/FMedia_ImageBufferImpl.cpp
src/FMedia_ImageImpl.cpp

index 4f3556f..5f206cd 100644 (file)
@@ -165,6 +165,42 @@ _GifDecoderImpl::GetNextBitmapN(long& duration, Tizen::Graphics::BufferScaling b
                                        ? BITMAP_PIXEL_FORMAT_RGB565 : BITMAP_PIXEL_FORMAT_ARGB8888;
                r = pBitmap->Construct(*pByteBuffer.get(), dim, pixelFormat, bufferScaling);
                SysTryReturn(NID_MEDIA, r == E_SUCCESS, null,r, "pBmp->Construct:%s", GetErrorMessage(r));
+
+                       // Set transparency in case of rgb565 format
+               if (pixelFormat == BITMAP_PIXEL_FORMAT_RGB565)
+               {
+                       short rgb565Chroma = 0;
+                       Boolean transparency(false);
+                       Integer chromaKey(0);
+                       byte red = 0;
+                       byte green = 0;
+                       byte blue = 0;
+                       Color *pMaskingColor = null;
+
+                       r = __pGifDecoder->GetValue(L"transparency", transparency);
+                       SysTryReturn(NID_MEDIA, r == E_SUCCESS, pBitmap.release(), E_SUCCESS, "[%s] Propagated.", GetErrorMessage(r));
+                       if (transparency.ToBool() == true)
+                       {
+                               r = __pGifDecoder->GetValue(L"chromaKey", chromaKey);
+                               SysTryReturn(NID_MEDIA, r == E_SUCCESS, pBitmap.release(), E_SUCCESS, "[%s] Propagated.", GetErrorMessage(r));
+
+                               rgb565Chroma = chromaKey.ToShort();
+                               red = (rgb565Chroma & 0xf800) >> 8;
+                               red = red | (red >> 5);
+                               green = (rgb565Chroma & 0x07e0) >> 3;
+                               green = green | (green >> 6);
+                               blue = (rgb565Chroma & 0x001f) << 3;
+                               blue = blue | (blue >> 5);
+
+                               pMaskingColor = new Color(red, green, blue);
+                               SysTryReturn(NID_MEDIA, pMaskingColor != null, pBitmap.release(), E_SUCCESS,
+                                       "[%s] Could not apply masking color.", GetErrorMessage(r));
+                               r = pBitmap->SetMaskingColor(pMaskingColor);
+                               delete pMaskingColor;
+                               SysTryReturn(NID_MEDIA, r == E_SUCCESS, pBitmap.release(), E_SUCCESS,
+                                       "[%s] Could not set masking color.", GetErrorMessage(r));
+                       }
+               }
        }
        SetLastResult(E_SUCCESS);
        return pBitmap.release();
index 2210c1c..e280ddc 100644 (file)
@@ -200,7 +200,7 @@ _ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, const Ti
        Tizen::Graphics::Rectangle transformRegion;
        int orientationInfo = 0;
        Boolean transparency(false);
-       Integer chromaKey;
+       Integer chromaKey(0);
 
        r = dec.Construct(srcImageBuf);
        SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Decoder construct failed.", GetErrorMessage(r));
@@ -329,7 +329,7 @@ _ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, const Ti
                                        }
                                        else
                                        {
-                                               __maskColor = chromaKey.ToInt();
+                                               __maskColor = chromaKey.value;
                                        }
                                }
                        }
@@ -376,7 +376,7 @@ _ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, const Ti
                                        }
                                        else
                                        {
-                                               __maskColor = chromaKey.ToInt();
+                                               __maskColor = chromaKey.value;
                                        }
                                }
                        }
@@ -413,7 +413,7 @@ _ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, const Ti
                                }
                                else
                                {
-                                       __maskColor = chromaKey.ToInt();
+                                       __maskColor = chromaKey.value;
                                }
                        }
                }
@@ -528,7 +528,7 @@ _ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, int dest
        std::unique_ptr<byte[]> pDstBuf;
        Tizen::Graphics::Rectangle transformRegion;
        Boolean transparency(false);
-       Integer chromaKey;
+       Integer chromaKey(0);
 
        r = dec.Construct(srcImageBuf);
        SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Decoder construct failed.", GetErrorMessage(r));
@@ -574,7 +574,7 @@ _ImageBufferImpl::Construct(const Tizen::Base::ByteBuffer &srcImageBuf, int dest
                        }
                        else
                        {
-                               __maskColor = chromaKey.ToInt();
+                               __maskColor = chromaKey.value;
                        }
                }
        }
index a32ed92..6567bce 100644 (file)
@@ -168,7 +168,7 @@ _ImageImpl::DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::G
        {
                short rgb565Chroma = 0;
                Boolean transparency(false);
-               Short chromaKey(0);
+               Integer chromaKey(0);
                byte red = 0;
                byte green = 0;
                byte blue = 0;
@@ -255,7 +255,7 @@ _ImageImpl::DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::G
        {
                short rgb565Chroma = 0;
                Boolean transparency(false);
-               Short chromaKey(0);
+               Integer chromaKey(0);
                byte red = 0;
                byte green = 0;
                byte blue = 0;
@@ -335,7 +335,7 @@ _ImageImpl::DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::G
        {
                short rgb565Chroma = 0;
                Boolean transparency(false);
-               Short chromaKey(0);
+               Integer chromaKey(0);
                byte red = 0;
                byte green = 0;
                byte blue = 0;