+Bitmap*
+_ImageImpl::DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat,
+ const Tizen::Graphics::FloatDimension &destDim)
+{
+ result r = E_SUCCESS;
+ std::unique_ptr<ByteBuffer> pBuf;
+ std::unique_ptr<Bitmap> pBmp;
+ Dimension orgDim, tmpDim;
+ FloatDimension outDim;
+ BufferInfo bufInfo;
+
+ _ImageDecoder dec;
+
+ r = dec.Construct(srcImageBuf, _ImageUtilImpl::ToMediaPixelFormat(pixelFormat));
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Decoder construct failed.", GetErrorMessage(r));
+
+ r = dec.GetDimension(orgDim.width, orgDim.height);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+ // Reset decoder output demension
+ dec.SetOutputDimension(_CoordinateSystemUtils::ConvertToInteger(destDim.width),
+ _CoordinateSystemUtils::ConvertToInteger(destDim.height),
+ true);
+
+ pBuf.reset(dec.DecodeN());
+ SysTryReturn(NID_MEDIA, pBuf.get() != null, null, GetLastResult(),
+ "[%s] Propagated", GetErrorMessage(GetLastResult()));
+
+ r = dec.GetDimension(tmpDim.width, tmpDim.height);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+ r = _ImageUtil::GetResizedDimension(orgDim.width, orgDim.height, destDim.width, destDim.height, outDim.width, outDim.height);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+ pBmp.reset(new (std::nothrow) Bitmap);
+ SysTryReturn(NID_MEDIA, pBmp.get() != null, null, E_OUT_OF_MEMORY,
+ "[%s] new Bitmap", GetErrorMessage(GetLastResult()));
+
+ pBmp.reset(_BitmapImpl::GetNonScaledBitmapN(*pBuf.get(), tmpDim, pixelFormat));
+ SetLastResult(E_SUCCESS);
+ return pBmp.release();
+}
+
+Bitmap*
+_ImageImpl::DecodeToBitmapN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat,
+ const Tizen::Graphics::FloatDimension &destDim)
+{
+ std::unique_ptr<ByteBuffer> pBuf;
+ Bitmap* pBmp = null;
+
+ pBuf.reset(_MediaUtil::FileToBufferN(srcImagePath));
+ SysTryReturn(NID_MEDIA, pBuf.get() != null, null, GetLastResult(),
+ "[%s] FileToBufferN %S", GetErrorMessage(GetLastResult()), srcImagePath.GetPointer());
+
+ pBmp = DecodeToBitmapN(*pBuf.get(), pixelFormat, destDim);
+ return pBmp;
+}
+