#include <FBaseSysLog.h>
#include "FMedia_MediaUtil.h"
#include "FMedia_ImageImpl.h"
+#include "FMedia_ImageUtil.h"
#include "FMedia_ImageUtilImpl.h"
#include "FMedia_ImageDecoder.h"
#include "FMedia_ImageEncoder.h"
#include "FMedia_ImageUriDataFactory.h"
+#include "FGrp_BitmapImpl.h"
+#include "FUi_CoordinateSystemUtils.h"
+
using namespace Tizen::Graphics;
using namespace Tizen::Base;
using namespace Tizen::Io;
+using namespace Tizen::Ui;
namespace Tizen { namespace Media
{
return E_SUCCESS;
}
+Bitmap*
+_ImageImpl::DecodeToBitmapN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat)
+{
+ 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);
+ return pBmp;
+}
+
+Bitmap*
+_ImageImpl::DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat)
+{
+ result r = E_SUCCESS;
+ std::unique_ptr<ByteBuffer> pBuf;
+ std::unique_ptr<Bitmap> pBmp;
+ Dimension outDim;
+
+ _ImageDecoder dec;
+
+ r = dec.Construct(srcImageBuf, _ImageUtilImpl::ToMediaPixelFormat(pixelFormat));
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Decoder construct failed.", GetErrorMessage(r));
+
+ pBuf.reset(dec.DecodeN());
+ SysTryReturn(NID_MEDIA, pBuf.get() != null, null, GetLastResult(),
+ "[%s] Propagated", GetErrorMessage(GetLastResult()));
+ r = GetLastResult();
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+ r = dec.GetDimension(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 != null, null, E_OUT_OF_MEMORY,
+ "[%s] new Bitmap", GetErrorMessage(GetLastResult()));
+ r = pBmp->Construct(*pBuf.get(), outDim, pixelFormat, BUFFER_SCALING_AUTO);
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+ SetLastResult(E_SUCCESS);
+ return pBmp.release();
+}
+
Bitmap*
-_ImageImpl::DecodeToBitmapN(const String& srcImgPath, BitmapPixelFormat pixelFormat,
- const Tizen::Graphics::Dimension &dstDim,
- Tizen::Graphics::BufferScaling bufferScaling,
- ImageFormat imgFormat, bool keepAspectRatio)
+_ImageImpl::DecodeToBitmapN(const Tizen::Base::String& srcImagePath, Tizen::Graphics::BitmapPixelFormat pixelFormat, const Tizen::Graphics::Dimension &destDim,
+ Tizen::Graphics::BufferScaling bufferScaling)
{
std::unique_ptr<ByteBuffer> pBuf;
Bitmap* pBmp = null;
- pBuf.reset(_MediaUtil::FileToBufferN(srcImgPath));
+ pBuf.reset(_MediaUtil::FileToBufferN(srcImagePath));
SysTryReturn(NID_MEDIA, pBuf.get() != null, null, GetLastResult(),
- "[%s] FileToBufferN %S", GetErrorMessage(GetLastResult()), srcImgPath.GetPointer());
+ "[%s] FileToBufferN %S", GetErrorMessage(GetLastResult()), srcImagePath.GetPointer());
- pBmp = DecodeToBitmapN(*pBuf.get(), pixelFormat, dstDim, bufferScaling, imgFormat, keepAspectRatio);
+ pBmp = DecodeToBitmapN(*pBuf.get(), pixelFormat, destDim, bufferScaling);
return pBmp;
}
-Tizen::Graphics::Bitmap*
-_ImageImpl::DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf,
- Tizen::Graphics::BitmapPixelFormat pixelFormat,
- const Tizen::Graphics::Dimension &dstDim,
- Tizen::Graphics::BufferScaling bufferScaling,
- ImageFormat imgFormat, bool keepAspectRatio)
+Bitmap*
+_ImageImpl::DecodeToBitmapN(const Tizen::Base::ByteBuffer& srcImageBuf, Tizen::Graphics::BitmapPixelFormat pixelFormat, const Tizen::Graphics::Dimension &destDim,
+ Tizen::Graphics::BufferScaling bufferScaling)
{
result r = E_SUCCESS;
std::unique_ptr<ByteBuffer> pBuf;
std::unique_ptr<Bitmap> pBmp;
Dimension outDim;
- //SysTryCatch(NID_MEDIA, IS_VALID_BITMAP_PIXEL(pixelFormat), , E_INVALID_ARG,
- // "[E_INVALID_ARG] pixelFormat:%d", pixelFormat);
- //SysTryCatch(NID_MEDIA, IS_VALID_DIMENSION(dstDim), , E_OUT_OF_RANGE,
- // "[E_OUT_OF_RANGE] dest dimension:%d,%d", dstDim.width, dstDim.height);
+ _ImageDecoder dec;
- pBuf.reset(DecodeToBufferN(srcImageBuf, outDim, dstDim, pixelFormat, imgFormat, keepAspectRatio));
+ r = dec.Construct(srcImageBuf, _ImageUtilImpl::ToMediaPixelFormat(pixelFormat));
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Decoder construct failed.", GetErrorMessage(r));
+
+ // Reset decoder output demension
+ dec.SetOutputDimension(destDim.width, destDim.height, true);
+
+ pBuf.reset(dec.DecodeN());
SysTryReturn(NID_MEDIA, pBuf.get() != null, null, GetLastResult(),
"[%s] Propagated", GetErrorMessage(GetLastResult()));
+ r = GetLastResult();
+ SysTryReturn(NID_MEDIA, r == E_SUCCESS, null, r, "[%s] Propagated. ", GetErrorMessage(r));
+
+ r = dec.GetDimension(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 != null, null, E_OUT_OF_MEMORY,
return pBmp.release();
}
+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;
+}
+
Tizen::Base::ByteBuffer*
_ImageImpl::DecodeToBufferN(const Tizen::Base::String& srcImagePath,
Tizen::Graphics::Dimension &restDim,