}
Bitmap*
-_AppResourceBitmap::GetBitmapN(const String& imageFileName, BitmapPixelFormat pixelFormat) const
+_AppResourceBitmap::GetBitmapN(const String& imageFileName, BitmapPixelFormat pixelFormat, bool lazyDecoding) const
{
ClearLastResult();
SysTryReturn(NID_APP, imageFileName.IsEmpty() == false, null, E_INVALID_ARG, "[%s] The specified input parameter is invalid.", imageFileName.GetPointer());
{
if (_ImageUtil::HasAlphaChannel(resourcePath))
{
- pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, BITMAP_PIXEL_FORMAT_ARGB8888, imageScaling);
+ pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, BITMAP_PIXEL_FORMAT_ARGB8888, imageScaling, null, lazyDecoding);
}
else
{
const Color& magentaColor = Color::GetColor(COLOR_ID_MAGENTA);
- pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, BITMAP_PIXEL_FORMAT_RGB565, imageScaling, &magentaColor);
+ pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, BITMAP_PIXEL_FORMAT_RGB565, imageScaling, &magentaColor, lazyDecoding);
}
}
else
{
- pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, pixelFormat, imageScaling);
+ pBitmap = __pAppResourceBitmapUtil->GetBitmapN(resourcePath, resourceDensity, pixelFormat, imageScaling, null, lazyDecoding);
}
-
- SysSecureLog(NID_APP, "The current value of bitmap path is %S(%S) and pixel format is %d", resourcePath.GetPointer(), imageScaling?L"scaled":L"not scaled", pixelFormat);
-
r = GetLastResult();
- SysTryReturn(NID_APP, pBitmap != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
+ SysTryReturn(NID_APP, (pBitmap != null) && (r == E_SUCCESS), null, r, "[%s] Propagating.", GetErrorMessage(r));
+ SysSecureLog(NID_APP, "The current value of bitmap path is %S(%S) and pixel format is %d", resourcePath.GetPointer(), imageScaling?L"scaled":L"not scaled", pixelFormat);
return pBitmap;
}
* @remarks The specific error code can be accessed using the GetLastResult() method.
* @remarks There is a high probability for an occurrence of an out-of-memory exception. If possible, check whether the exception is E_OUT_OF_MEMORY or not. For more information on how to handle the out-of-memory exception, refer <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/exception_check.htm">here</a>.
*/
- virtual Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat) const;
+ virtual Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& imagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat, bool lazyDecoding = true) const;
static _AppResourceBitmap* Get_AppResourceBitmapN(int type, const Tizen::Base::String& value);
// GetBitmapN
Bitmap*
_AppResourceBitmapUtil::GetBitmapN(const String& resourcePath, const _Density resourceDensity,
- BitmapPixelFormat pixelFormat, bool imageScaling, const Color* pChromaKeyColor) const
+ BitmapPixelFormat pixelFormat, bool imageScaling, const Color* pChromaKeyColor, bool lazyDecoding) const
{
ClearLastResult();
SysTryReturn(NID_APP, (pixelFormat > BITMAP_PIXEL_FORMAT_MIN && pixelFormat < BITMAP_PIXEL_FORMAT_MAX), null,
if (!pChromaKeyColor && imageScaling == false) // NonScaling
{
- pBitmap.reset(new (std::nothrow) Bitmap());
- SysTryReturn(NID_APP, pBitmap != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
+ if (lazyDecoding)
+ {
+ pBitmap.reset(new (std::nothrow) Bitmap());
+ SysTryReturn(NID_APP, pBitmap != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
- r = _BitmapImpl::GetInstance(*pBitmap)->Construct(resourcePath, pixelFormat);
+ r = _BitmapImpl::GetInstance(*pBitmap)->Construct(resourcePath, pixelFormat);
+ }
+ else
+ {
+ MediaPixelFormat format = ConvertBitmapPixelFormatToMediaPixelFormat(pixelFormat);
+ int imageWidth(-1);
+ int imageHeight(-1);
+
+ std::unique_ptr<ByteBuffer> pBuffer(_ImageDecoder::DecodeToBufferN(resourcePath, format, imageWidth, imageHeight));
+ r = GetLastResult();
+ SysTryReturn(NID_APP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
+ SysTryReturn(NID_APP, pBuffer != null, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
+
+ pBitmap.reset(_BitmapImpl::GetNonScaledBitmapN(*pBuffer, Dimension(imageWidth, imageHeight), pixelFormat));
+ SysTryReturn(NID_APP, pBitmap != null, null, E_SYSTEM, "[E_SYSTEM] A system error has occurred.");
+ r = GetLastResult();
+ }
SysTryReturn(NID_APP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
return pBitmap.release();
// Create Bitmap from real image path
Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& resourcePath, _Density resourceDensity,
- Tizen::Graphics::BitmapPixelFormat pixelFormat, bool imageScaling, const Tizen::Graphics::Color* pChromaKeyColor = null) const;
+ Tizen::Graphics::BitmapPixelFormat pixelFormat, bool imageScaling, const Tizen::Graphics::Color* pChromaKeyColor = null, bool lazyDecoding = true) const;
static _AppResourceBitmapUtil* GetInstanceN(int type = APP_RESOURCE_DEFAULT, const Tizen::Base::String& value = L"");