, __orientation(EXIF_ORIENTATION_TOP_LEFT)
, __pixelFormat(MEDIA_PIXEL_FORMAT_NONE)
, __isLocked(false)
+ , __transparent(false)
+ , __maskColor(0xf81f) // MAGENTA
{
}
std::unique_ptr<byte[]> pDstBuf;
Tizen::Graphics::Rectangle transformRegion;
int orientationInfo = 0;
+ Boolean transparency(false);
+ Integer chromaKey;
r = dec.Construct(srcImageBuf);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Decoder construct failed.", GetErrorMessage(r));
__pBuffer.reset(dec.DecodeN(__bufSize));
SysTryReturn(NID_MEDIA, __pBuffer.get() != null, r, r,
"[%s] DecodeN returned empty buffer.", GetErrorMessage(r));
+ r = dec.GetValue("transparency", transparency);
+ if (r != E_SUCCESS)
+ {
+ __transparent = false;
+ r = E_SUCCESS;
+ }
+ else
+ {
+ __transparent = transparency.ToBool();
+ if (__transparent == true)
+ {
+ r = dec.GetValue(L"chromaKey", chromaKey);
+ if (r != E_SUCCESS)
+ {
+ __transparent = false;
+ r = E_SUCCESS;
+ }
+ else
+ {
+ __maskColor = chromaKey.ToInt();
+ }
+ }
+ }
}
else if (r == E_UNSUPPORTED_OPERATION)
{
__bufSize = _ImageUtil::GetBufferSize(__pixelFormat, pDecodingRegion->width, pDecodingRegion->height);
SysTryReturn(NID_MEDIA, __bufSize > 0, GetLastResult(), GetLastResult(),
"[%s] Could not get output buffer size.", GetErrorMessage(GetLastResult()));
+
+ r = dec.GetValue("transparency", transparency);
+ if (r != E_SUCCESS)
+ {
+ __transparent = false;
+ r = E_SUCCESS;
+ }
+ else
+ {
+ __transparent = transparency.ToBool();
+ if (__transparent == true)
+ {
+ r = dec.GetValue(L"chromaKey", chromaKey);
+ if (r != E_SUCCESS)
+ {
+ __transparent = false;
+ r = E_SUCCESS;
+ }
+ else
+ {
+ __maskColor = chromaKey.ToInt();
+ }
+ }
+ }
}
}
else
SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] DecodeN failed.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, __pBuffer.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] Propagated.");
+
+ r = dec.GetValue("transparency", transparency);
+ if (r != E_SUCCESS)
+ {
+ __transparent = false;
+ r = E_SUCCESS;
+ }
+ else
+ {
+ __transparent = transparency.ToBool();
+ if (__transparent == true)
+ {
+ r = dec.GetValue(L"chromaKey", chromaKey);
+ if (r != E_SUCCESS)
+ {
+ __transparent = false;
+ r = E_SUCCESS;
+ }
+ else
+ {
+ __maskColor = chromaKey.ToInt();
+ }
+ }
+ }
}
if (autoRotate == true)
_ImageDecoder dec;
std::unique_ptr<byte[]> pDstBuf;
Tizen::Graphics::Rectangle transformRegion;
+ Boolean transparency(false);
+ Integer chromaKey;
r = dec.Construct(srcImageBuf);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Decoder construct failed.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, __pBuffer.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
"[E_OUT_OF_MEMORY] Propagated.");
+ r = dec.GetValue("transparency", transparency);
+ if (r != E_SUCCESS)
+ {
+ __transparent = false;
+ r = E_SUCCESS;
+ }
+ else
+ {
+ __transparent = transparency.ToBool();
+ if (__transparent == true)
+ {
+ r = dec.GetValue(L"chromaKey", chromaKey);
+ if (r != E_SUCCESS)
+ {
+ __transparent = false;
+ r = E_SUCCESS;
+ }
+ else
+ {
+ __maskColor = chromaKey.ToInt();
+ }
+ }
+ }
+
r = dec.GetDimension(__width, __height);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] GetDimension failed.",
GetErrorMessage(r));
r = pOutBitmap->Construct(*pTmpByteBuffer.get(), Dimension(__width, __height), pixelFormat, bufferScaling);
}
+ if ((__transparent == true) && (pixelFormat == BITMAP_PIXEL_FORMAT_RGB565))
+ {
+ byte red = 0;
+ byte green = 0;
+ byte blue = 0;
+ Color *pMaskingColor = null;
+
+ if (__pixelFormat == MEDIA_PIXEL_FORMAT_BGRA8888)
+ {
+ blue = (__maskColor & 0x000000ff);
+ green = (__maskColor & 0x0000ff00) >> 8;
+ red = (__maskColor & 0x00ff0000) >> 16;
+ }
+ else
+ {
+ red = (__maskColor & 0xf800) >> 8;
+ red = red | (red >> 5);
+ green = (__maskColor & 0x07e0) >> 3;
+ green = green | (green >> 6);
+ blue = (__maskColor & 0x001f) << 3;
+ blue = blue | (blue >> 5);
+ }
+
+ pMaskingColor = new Color(red, green, blue);
+ SysTryReturn(NID_MEDIA, pMaskingColor != null, pOutBitmap.release(), E_SUCCESS,
+ "[%s] Could not apply masking color.", GetErrorMessage(r));
+ r = pOutBitmap->SetMaskingColor(pMaskingColor);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, pOutBitmap.release(), E_SUCCESS,
+ "[%s] Could not set masking color.", GetErrorMessage(r));
+ delete pMaskingColor;
+ }
+
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated.",
GetErrorMessage(r));
return pOutBitmap.release();
pOutBitmap.reset(_BitmapImpl::GetNonScaledBitmapN(*pOutBuf.get(), convertDim, pixelFormat, destDim));
}
+ if ((__transparent == true) && (pixelFormat == BITMAP_PIXEL_FORMAT_RGB565))
+ {
+ byte red = 0;
+ byte green = 0;
+ byte blue = 0;
+ Color *pMaskingColor = null;
+
+ if (__pixelFormat == MEDIA_PIXEL_FORMAT_BGRA8888)
+ {
+ blue = (__maskColor & 0x000000ff);
+ green = (__maskColor & 0x0000ff00) >> 8;
+ red = (__maskColor & 0x00ff0000) >> 16;
+ }
+ else
+ {
+ red = (__maskColor & 0xf800) >> 8;
+ red = red | (red >> 5);
+ green = (__maskColor & 0x07e0) >> 3;
+ green = green | (green >> 6);
+ blue = (__maskColor & 0x001f) << 3;
+ blue = blue | (blue >> 5);
+ }
+
+ pMaskingColor = new Color(red, green, blue);
+ SysTryReturn(NID_MEDIA, pMaskingColor != null, pOutBitmap.release(), E_SUCCESS,
+ "[%s] Could not apply masking color.", GetErrorMessage(r));
+ r = pOutBitmap->SetMaskingColor(pMaskingColor);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, pOutBitmap.release(), E_SUCCESS,
+ "[%s] Could not set masking color.", GetErrorMessage(r));
+ delete pMaskingColor;
+ }
+
SysTryReturn(NID_MEDIA, pOutBitmap.get() != null, null, GetLastResult(), "[%s] Propagated.", GetErrorMessage(GetLastResult()));
return pOutBitmap.release();
}
byte* pData = null;
int length = 0;
MediaPixelFormat pixFmt = MEDIA_PIXEL_FORMAT_NONE;
+ _ImageBufferImpl* pClonedImpl = null;
r = const_cast<_ImageBufferImpl *>(this)->Lock(pData, length, pixFmt);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, pImgBuffer.get(), r, "[%s] Propagated.", GetErrorMessage(r));
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r,
"[%s] Failed to construct the cloned ImageBuffer.", GetErrorMessage(r));
+ pClonedImpl = GetInstance(*pImgBuffer);
+ SysTryReturn(NID_MEDIA, pClonedImpl != null, null, r,
+ "[%s] Failed to GetInstance.", GetErrorMessage(r));
+ pClonedImpl->__maskColor = __maskColor;
+ pClonedImpl->__transparent = __transparent;
+
const_cast<_ImageBufferImpl *>(this)->Unlock();
SetLastResult(r);
int length = 0;
int dstLength = 0;
MediaPixelFormat pixFmt = MEDIA_PIXEL_FORMAT_NONE;
+ _ImageBufferImpl* pConvertedImpl = null;
SysTryReturn(NID_MEDIA, ISSUPPORTED(pixelFormat) == true, pImgBuffer.get(), E_INVALID_ARG,
"[E_INVALID_ARG] Pixel format %d is not supported.", pixelFormat);
r = pImgBuffer->Construct(__width, __height, pixelFormat, pDataConvert.get(), dstLength);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r,
"[%s] Failed to construct the converted ImageBuffer.", GetErrorMessage(r));
+
+ pConvertedImpl = GetInstance(*pImgBuffer);
+ SysTryReturn(NID_MEDIA, pConvertedImpl != null, null, r,
+ "[%s] Failed to GetInstance.", GetErrorMessage(r));
+ pConvertedImpl->__maskColor = __maskColor;
+ pConvertedImpl->__transparent = __transparent;
}
else
{
int length = 0;
int dstLength = 0;
MediaPixelFormat pixFmt = MEDIA_PIXEL_FORMAT_NONE;
+ _ImageBufferImpl* pResizedImpl = null;
SysTryReturn(NID_MEDIA, (width > 0) && (height > 0), pImgBuffer.get(), E_INVALID_ARG,
"[E_INVALID_ARG] Dimensions should be greater than zero: (%d x %d)", width, height);
r = pImgBuffer->Construct(width, height, __pixelFormat, pDataResized.get(), dstLength);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r,
"[%s] Failed to construct the resized ImageBuffer.", GetErrorMessage(r));
+
+ pResizedImpl = GetInstance(*pImgBuffer);
+ SysTryReturn(NID_MEDIA, pResizedImpl != null, null, r,
+ "[%s] Failed to GetInstance.", GetErrorMessage(r));
+ pResizedImpl->__maskColor = __maskColor;
+ pResizedImpl->__transparent = __transparent;
}
else
{
std::unique_ptr<byte[]> pDataFlip;
int length = 0;
MediaPixelFormat pixFmt = MEDIA_PIXEL_FORMAT_NONE;
+ _ImageBufferImpl* pFlippedImpl = null;
SysTryReturn(NID_MEDIA, (flipType >= IMAGE_FLIP_NONE) && (flipType <= IMAGE_FLIP_VERTICAL),
pImgBuffer.get(), E_INVALID_ARG, "[E_INVALID_ARG] Flip type is not valid: %d.", flipType);
r = pImgBuffer->Construct(__width, __height, __pixelFormat, pDataFlip.get(), length);
SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r,
"[%s] Failed to construct the fliped ImageBuffer.", GetErrorMessage(r));
+
+ pFlippedImpl = GetInstance(*pImgBuffer);
+ SysTryReturn(NID_MEDIA, pFlippedImpl != null, null, r,
+ "[%s] Failed to GetInstance.", GetErrorMessage(r));
+ pFlippedImpl->__maskColor = __maskColor;
+ pFlippedImpl->__transparent = __transparent;
}
else
{
int rotatedWidth= 0;
int rotatedHeight = 0;
MediaPixelFormat pixFmt = MEDIA_PIXEL_FORMAT_NONE;
+ _ImageBufferImpl* pRotatedImpl = null;
SysTryReturn(NID_MEDIA, (rotationType >= IMAGE_ROTATION_0) && (rotationType <= IMAGE_ROTATION_270),
pImgBuffer.get(), E_INVALID_ARG, "[E_INVALID_ARG] Rotation type is not valid: %d.", rotationType);
r = pImgBuffer->Construct(rotatedWidth, rotatedHeight, __pixelFormat, pDataRotate.get(), length);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r,
"[%s] Failed to construct the rotated ImageBuffer.", GetErrorMessage(r));
+
+ pRotatedImpl = GetInstance(*pImgBuffer);
+ SysTryReturn(NID_MEDIA, pRotatedImpl != null, null, r,
+ "[%s] Failed to GetInstance.", GetErrorMessage(r));
+ pRotatedImpl->__maskColor = __maskColor;
+ pRotatedImpl->__transparent = __transparent;
}
else
{
int length = 0;
int dstLength = 0;
MediaPixelFormat pixFmt = MEDIA_PIXEL_FORMAT_NONE;
+ _ImageBufferImpl *pCroppedImpl = null;
SysTryReturn(NID_MEDIA, (x >= 0) && (y >= 0) && (x <= __width) && (y <= __height),
pImgBuffer.get(), E_INVALID_ARG,
r = pImgBuffer->Construct(width, height, __pixelFormat, pDataCropped.get(), dstLength);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r,
"[%s] Failed to construct the croped ImageBuffer.", GetErrorMessage(r));
+
+ pCroppedImpl = GetInstance(*pImgBuffer);
+ SysTryReturn(NID_MEDIA, pCroppedImpl != null, null, r,
+ "[%s] Failed to GetInstance.", GetErrorMessage(r));
+ pCroppedImpl->__maskColor = __maskColor;
+ pCroppedImpl->__transparent = __transparent;
}
else
{
bool
_ImageBufferImpl::IsSupportedPixelFormat(MediaPixelFormat pixelFormat)
{
- for (int i = 0; i < sizeof(_IMAGE_BUFFER_PIXEL_FORMATS)/sizeof(_IMAGE_BUFFER_PIXEL_FORMATS[0]) ; i++)
+ for (unsigned int i = 0; i < sizeof(_IMAGE_BUFFER_PIXEL_FORMATS)/sizeof(_IMAGE_BUFFER_PIXEL_FORMATS[0]) ; i++)
{
if(pixelFormat == _IMAGE_BUFFER_PIXEL_FORMATS[i])
{
"[E_OUT_OF_MEMORY] Could not allocate memory for output.");
// TODO update list later for supported color formats in color converter?.
- for (int i=0; i<sizeof(_IMAGE_BUFFER_PIXEL_FORMATS)/sizeof(_IMAGE_BUFFER_PIXEL_FORMATS[0]); i++)
+ for (unsigned int i=0; i<sizeof(_IMAGE_BUFFER_PIXEL_FORMATS)/sizeof(_IMAGE_BUFFER_PIXEL_FORMATS[0]); i++)
{
r = pList->Add(_IMAGE_BUFFER_PIXEL_FORMATS[i]);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r,
r = pBmp->Construct(*pBuf.get(), outDim, pixelFormat, BUFFER_SCALING_AUTO);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+ // Set transparency in case of rgb565 format
+ if (pixelFormat == BITMAP_PIXEL_FORMAT_RGB565)
+ {
+ short rgb565Chroma = 0;
+ Boolean transparency(false);
+ Short chromaKey(0);
+ byte red = 0;
+ byte green = 0;
+ byte blue = 0;
+ Color *pMaskingColor = null;
+
+ r = dec.GetValue(L"transparency", transparency);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, pBmp.release(), E_SUCCESS, "[%s] Propagated.", GetErrorMessage(r));
+ if (transparency.ToBool() == true)
+ {
+ r = dec.GetValue(L"chromaKey", chromaKey);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, pBmp.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, pBmp.release(), E_SUCCESS,
+ "[%s] Could not apply masking color.", GetErrorMessage(r));
+ r = pBmp->SetMaskingColor(pMaskingColor);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, pBmp.release(), E_SUCCESS,
+ "[%s] Could not set masking color.", GetErrorMessage(r));
+ }
+ }
+
SetLastResult(E_SUCCESS);
return pBmp.release();
}
r = pBmp->Construct(*pBuf.get(), outDim, pixelFormat, bufferScaling);
SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+ // Set transparency in case of rgb565 format
+ if (pixelFormat == BITMAP_PIXEL_FORMAT_RGB565)
+ {
+ short rgb565Chroma = 0;
+ Boolean transparency(false);
+ Short chromaKey(0);
+ byte red = 0;
+ byte green = 0;
+ byte blue = 0;
+ Color *pMaskingColor = null;
+
+ r = dec.GetValue(L"transparency", transparency);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, pBmp.release(), E_SUCCESS, "[%s] Propagated.", GetErrorMessage(r));
+ if (transparency.ToBool() == true)
+ {
+ r = dec.GetValue(L"chromaKey", chromaKey);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, pBmp.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, pBmp.release(), E_SUCCESS,
+ "[%s] Could not apply masking color.", GetErrorMessage(r));
+ r = pBmp->SetMaskingColor(pMaskingColor);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, pBmp.release(), E_SUCCESS,
+ "[%s] Could not set masking color.", GetErrorMessage(r));
+ }
+ }
+
SetLastResult(E_SUCCESS);
return pBmp.release();
}
"[%s] new Bitmap", GetErrorMessage(GetLastResult()));
pBmp.reset(_BitmapImpl::GetNonScaledBitmapN(*pBuf.get(), tmpDim, pixelFormat, destDim));
+
+ // Set transparency in case of rgb565 format
+ if (pixelFormat == BITMAP_PIXEL_FORMAT_RGB565)
+ {
+ short rgb565Chroma = 0;
+ Boolean transparency(false);
+ Short chromaKey(0);
+ byte red = 0;
+ byte green = 0;
+ byte blue = 0;
+ Color *pMaskingColor = null;
+
+ r = dec.GetValue(L"transparency", transparency);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, pBmp.release(), E_SUCCESS, "[%s] Propagated.", GetErrorMessage(r));
+ if (transparency.ToBool() == true)
+ {
+ r = dec.GetValue(L"chromaKey", chromaKey);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, pBmp.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, pBmp.release(), E_SUCCESS,
+ "[%s] Could not apply masking color.", GetErrorMessage(r));
+ r = pBmp->SetMaskingColor(pMaskingColor);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, pBmp.release(), E_SUCCESS,
+ "[%s] Could not set masking color.", GetErrorMessage(r));
+ }
+ }
+
SetLastResult(E_SUCCESS);
return pBmp.release();
}