From c647a76959cc2a10218edd7a40af2faa0aa4bf4f Mon Sep 17 00:00:00 2001 From: leda Date: Tue, 28 Aug 2018 09:47:16 +0800 Subject: [PATCH] improve text texture RGB value on win32 (#1473) * fix text texture RGB error on win32 * keep alpha value, no change --- .../win32/CCCanvasRenderingContext2D-win32.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/native/cocos/platform/win32/CCCanvasRenderingContext2D-win32.cpp b/native/cocos/platform/win32/CCCanvasRenderingContext2D-win32.cpp index d6d13432b5..75ceb0a8ad 100644 --- a/native/cocos/platform/win32/CCCanvasRenderingContext2D-win32.cpp +++ b/native/cocos/platform/win32/CCCanvasRenderingContext2D-win32.cpp @@ -535,10 +535,8 @@ private: GetDIBits(_DC, _bmp, 0, _bufferHeight, dataBuf, (LPBITMAPINFO)&bi, DIB_RGB_COLORS); - uint8_t r = _fillStyle.r * 255.0f; - uint8_t g = _fillStyle.g * 255.0f; - uint8_t b = _fillStyle.b * 255.0f; - COLORREF textColor = (b << 16 | g << 8 | r) & 0x00ffffff; + + uint8_t r, g, b; float alpha = 1.0f; COLORREF * pPixel = nullptr; for (int y = 0; y < _bufferHeight; ++y) @@ -551,6 +549,11 @@ private: // "dirtyValue > 0" means pixel was covered when drawing text if (dirtyValue > 0) { + // r = _fillStyle.r * 255 * (dirtyValue / 255); + r = _fillStyle.r * dirtyValue; + g = _fillStyle.g * dirtyValue; + b = _fillStyle.b * dirtyValue; + COLORREF textColor = (b << 16 | g << 8 | r) & 0x00ffffff; clr = ((BYTE)(dirtyValue * alpha) << 24) | textColor; } ++pPixel;