}
Bitmap*
-_BitmapImpl::GetExpandedBitmapFN(const Bitmap& ninePatchedBitmap, float width, float height)
+_BitmapImpl::GetExpandedBitmapN(const Bitmap& ninePatchedBitmap, int width, int height)
{
- SysTryReturn(NID_GRP, width > 0.0f && height > 0.0f, null, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid (width = %f, height = %f)", width, height);
+ SysTryReturn(NID_GRP, width > 0 && height > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid (width = %d, height = %d)", width, height);
SysTryReturn(NID_GRP, &ninePatchedBitmap, null, E_INVALID_ARG, "[E_INVALID_ARG] The given bitmap is invalid (null reference passed)");
break;
}
- std::auto_ptr<Bitmap> expandedBitmap(new (std::nothrow) Bitmap);
-
- SysTryReturn(NID_GRP, expandedBitmap.get(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed (new Bitmap)");
-
- result r = expandedBitmap->Construct(FloatDimension(width, height), pixelFormat);
-
- SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
-
- _BitmapImpl* pDstBitmapImpl = _BitmapImpl::GetInstance(*expandedBitmap.get());
-
- SysAssert(pDstBitmapImpl != null);
-
- {
- _Util::LockManager srcBitmap(*pSrcBitmapImpl);
- _Util::LockManager dstBitmap(*pDstBitmapImpl);
-
- SysTryReturn(NID_GRP, srcBitmap.IsValid(), null, srcBitmap.GetResult(), "[%s] Buffer locking of the source bitmap failed", srcBitmap.GetResult());
- SysTryReturn(NID_GRP, dstBitmap.IsValid(), null, dstBitmap.GetResult(), "[%s] Buffer locking of the target bitmap failed", dstBitmap.GetResult());
-
- if (dstBitmap.GetBufferInfo().width < srcBitmap.GetBufferInfo().width - 2 ||
- dstBitmap.GetBufferInfo().height < srcBitmap.GetBufferInfo().height - 2)
- {
- // down-scales from the source bitmap only
- const BufferInfo& srcBufferInfo = srcBitmap.GetBufferInfo();
- const BufferInfo& dstBufferInfo = dstBitmap.GetBufferInfo();
-
- memset(dstBufferInfo.pPixels, 0, dstBufferInfo.pitch * dstBufferInfo.height);
-
- _Util::Pixmap dstImage(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, (void*) dstBufferInfo.pPixels, dstBufferInfo.pitch);
-
- Rectangle sourRect(1, 1, srcBufferInfo.width - 2, srcBufferInfo.height - 2);
- Rectangle destRect(0, 0, dstBufferInfo.width, dstBufferInfo.height);
-
- unsigned char* pSrcPixels = (unsigned char*) srcBufferInfo.pPixels + sourRect.y * srcBufferInfo.pitch + sourRect.x * (srcBufferInfo.bitsPerPixel / 8);
- _Util::Pixmap srcImage(sourRect.width, sourRect.height, srcBufferInfo.bitsPerPixel, (void*) pSrcPixels, srcBufferInfo.pitch);
-
- Tizen::Graphics::_Effect::ScaleImage(dstImage, destRect.x, destRect.y, destRect.width, destRect.height, srcImage, Tizen::Graphics::_Effect::ROP_COPY);
- }
- else
- {
- const BufferInfo& srcBufferInfo = srcBitmap.GetBufferInfo();
- const BufferInfo& dstBufferInfo = dstBitmap.GetBufferInfo();
-
- memset(dstBufferInfo.pPixels, 0, dstBufferInfo.pitch * dstBufferInfo.height);
-
- _Util::Pixmap dstImage(dstBufferInfo.width, dstBufferInfo.height, dstBufferInfo.bitsPerPixel, (void*) dstBufferInfo.pPixels, dstBufferInfo.pitch);
-
- _Util::AccumList<_Util::Pair<_Util::Rectangle<int>, _Util::Rectangle<int> > > boundsList;
-
- Rectangle destRect(0, 0, dstBufferInfo.width, dstBufferInfo.height);
-
- // assert(pSrcBitmapImpl->_nativeBitmap);
- r = _Util::GetPatchList(boundsList, destRect, *pSrcBitmapImpl->_sharedItem->nativeBitmap.get());
-
- SysTryReturn(NID_GRP, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] _Util::GetPatchList() failed (error = %#x)", r);
-
- _Util::AccumList<_Util::Pair<_Util::Rectangle<int>, _Util::Rectangle<int> > >::Iterator iter = boundsList.Begin();
-
- while (iter != boundsList.End())
- {
- Rectangle destRect(iter->first.x, iter->first.y, iter->first.w, iter->first.h);
- Rectangle sourRect(iter->second.x, iter->second.y, iter->second.w, iter->second.h);
-
- {
- unsigned char* pSrcPixels = (unsigned char*) srcBufferInfo.pPixels + sourRect.y * srcBufferInfo.pitch + sourRect.x * (srcBufferInfo.bitsPerPixel / 8);
- _Util::Pixmap srcImage(sourRect.width, sourRect.height, srcBufferInfo.bitsPerPixel, (void*) pSrcPixels, srcBufferInfo.pitch);
-
- Tizen::Graphics::_Effect::ScaleImage(dstImage, destRect.x, destRect.y, destRect.width, destRect.height, srcImage, Tizen::Graphics::_Effect::ROP_COPY);
- }
-
- ++iter;
- }
- }
- }
-
- return expandedBitmap.release();
+ return _BitmapImpl::GetExpandedBitmapFN(ninePatchedBitmap, float(width), float (height));
}
Bitmap*
-_BitmapImpl::GetExpandedBitmapN(const Bitmap& ninePatchedBitmap, int width, int height)
+_BitmapImpl::GetExpandedBitmapFN(const Bitmap& ninePatchedBitmap, float width, float height)
{
- SysTryReturn(NID_GRP, width > 0 && height > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid (width = %d, height = %d)", width, height);
+ SysTryReturn(NID_GRP, width > 0.0f && height > 0.0f, null, E_INVALID_ARG, "[E_INVALID_ARG] The given parameter is invalid (width = %f, height = %f)", width, height);
SysTryReturn(NID_GRP, &ninePatchedBitmap, null, E_INVALID_ARG, "[E_INVALID_ARG] The given bitmap is invalid (null reference passed)");
SysTryReturn(NID_GRP, expandedBitmap.get(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed (new Bitmap)");
- result r = expandedBitmap->Construct(Dimension(width, height), pixelFormat);
+ result r = expandedBitmap->Construct(FloatDimension(width, height), pixelFormat);
SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));