scaleFactorX = pCoordSys->GetTransformer()->GetHorizontalScaleFactor();
scaleFactorY = pCoordSys->GetTransformer()->GetVerticalScaleFactor();
- // WARNING:
- // 1. The values 'scaleFactorX' and 'scaleFactorY' may be greater than expected 'cause of float-error.
- // So, it is needed to cut-off some significant digits to ensure the scale factors are always less or equal than real values.
- // The cut-off position should be lower than the compensation value(> 10^3 due to rounding), too.
- // 2. The number fo siginificant digits for float is about 6 (5 for sure).
- // So, the scaleFactor to cut-off should be less or equal than 10^6.
-
- const float scaleFactor = 1000.0f / floatIntegralEpsilon;
- //SysAssert(scaleFactor <= 1000000.0f);
-
- scaleFactorX = floorf(scaleFactorX * scaleFactor) / scaleFactor;
- scaleFactorY = floorf(scaleFactorY * scaleFactor) / scaleFactor;
-
needScale = true;
}
#include <FGrpBufferInfo.h>
#include <FBaseByteBuffer.h>
#include <FGrp_CanvasImpl.h>
+#include <FGrp_BitmapImpl.h>
#include <FUiAnimIVisualElementAnimationStatusEventListener.h>
#include <FUiAnimVisualElementPropertyAnimation.h>
#include <FUiAnimVisualElementAnimationGroup.h>
if(pStart)
{
- byte* pCopy = new (std::nothrow) byte[info.height*(info.pitch)];
- if (pCopy)
- {
- memcpy(pCopy, pStart, info.height*(info.pitch));
+ ByteBuffer buffer;
+ result r = buffer.Construct(pStart, 0, info.height*(info.pitch), info.height*(info.pitch));
- for (int y = 0; y < info.height; y++)
+ if (r == E_SUCCESS)
+ {
+ Bitmap* pBitmap = Bitmap::GetNonScaledBitmapN(buffer, Dimension(info.width, info.height), BITMAP_PIXEL_FORMAT_ARGB8888);
+ if (pBitmap)
{
- for (int x = 0; x < info.width; x++)
- {
- unsigned int* pAddr = (unsigned int*)((unsigned char*)pCopy + info.pitch * y + x * 4);
- int a = ((*pAddr) >> 24) & 0xff;
- int r = ((*pAddr) >> 16) & 0xff;
- int g = ((*pAddr) >> 8) & 0xff;
- int b = ((*pAddr) >> 0) & 0xff;
- if (a > 0)
- {
- float fa = (float)a / 255.0f;
- r = r / fa;
- g = g / fa;
- b = b / fa;
- *pAddr = (a << 24) | (r << 16) | (g << 8) | b;
- }
- }
- }
+ _BitmapImpl::GetInstance(*pBitmap)->SetAsPremultiplied();
+ pBitmap->SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot() * 255.0f));
- ByteBuffer buffer;
- result r = buffer.Construct(pCopy, 0, info.height*(info.pitch), info.height*(info.pitch));
+ FloatRectangle outputRect(rectDest.x + bounds.x, rectDest.y + bounds.y, drawRect.width, drawRect.height);
- if (r == E_SUCCESS)
- {
- Bitmap* pBitmap = Bitmap::GetNonScaledBitmapN(buffer, Dimension(info.width, info.height), BITMAP_PIXEL_FORMAT_ARGB8888);
- if (pBitmap)
- {
- pBitmap->SetAlphaConstant((int)(pRenderTarget->GetOpacityFromRoot() * 255.0f));
- FloatRectangle outputRect(rectDest.x + bounds.x, rectDest.y + bounds.y, drawRect.width, drawRect.height);
- _VisualElementCoordinateSystem::ConvertRectangleToPhysicalIntegral(outputRect.x, outputRect.y, outputRect.width, outputRect.height);
- _VisualElementCoordinateSystem::ConvertRectangleToLogical(outputRect.x, outputRect.y, outputRect.width, outputRect.height);
-
- FloatRectangle srcRect(drawRect.x, drawRect.y, info.width, info.height);
- _VisualElementCoordinateSystem::ConvertDimensionToLogical(srcRect.width, srcRect.height);
-
- Rectangle outputR(outputRect.x, outputRect.y, outputRect.width, outputRect.height);
- Rectangle srcR(srcRect.x, srcRect.y, srcRect.width, srcRect.height);
- outputCanvas.DrawBitmap(outputR, *pBitmap, srcR);
-
- delete pBitmap;
- }
- }
+ _VisualElementCoordinateSystem::ConvertRectangleToPhysicalIntegral(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
+ _VisualElementCoordinateSystem::ConvertRectangleToLogical(drawRect.x, drawRect.y, drawRect.width, drawRect.height);
+
+ outputCanvas.DrawBitmap(outputRect, *pBitmap, drawRect);
- delete [] pCopy;
+ delete pBitmap;
+ }
}
}
}
_Colorf bgcolorf = pNativeNode->GetBackgroundColor();
Color color(bgcolorf.Red()*255, bgcolorf.Green()*255, bgcolorf.Blue()*255, bgcolorf.Alpha()*255);
- Point point;
+ FloatPoint point;
point.x = rectDest.x + bounds.x;
point.y = rectDest.y + bounds.y;