mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[gdi,shape] fix gdi_FillRect checks
This commit is contained in:
@@ -134,15 +134,11 @@ BOOL gdi_Ellipse(HGDI_DC hdc, int nLeftRect, int nTopRect, int nRightRect, int n
|
|||||||
|
|
||||||
BOOL gdi_FillRect(HGDI_DC hdc, const GDI_RECT* rect, HGDI_BRUSH hbr)
|
BOOL gdi_FillRect(HGDI_DC hdc, const GDI_RECT* rect, HGDI_BRUSH hbr)
|
||||||
{
|
{
|
||||||
UINT32 color = 0;
|
|
||||||
UINT32 dstColor = 0;
|
|
||||||
BOOL monochrome = FALSE;
|
|
||||||
INT32 nXDest = 0;
|
INT32 nXDest = 0;
|
||||||
INT32 nYDest = 0;
|
INT32 nYDest = 0;
|
||||||
INT32 nWidth = 0;
|
INT32 nWidth = 0;
|
||||||
INT32 nHeight = 0;
|
INT32 nHeight = 0;
|
||||||
const BYTE* srcp = NULL;
|
|
||||||
DWORD formatSize = 0;
|
|
||||||
if (!gdi_RectToCRgn(rect, &nXDest, &nYDest, &nWidth, &nHeight))
|
if (!gdi_RectToCRgn(rect, &nXDest, &nYDest, &nWidth, &nHeight))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -155,7 +151,8 @@ BOOL gdi_FillRect(HGDI_DC hdc, const GDI_RECT* rect, HGDI_BRUSH hbr)
|
|||||||
switch (hbr->style)
|
switch (hbr->style)
|
||||||
{
|
{
|
||||||
case GDI_BS_SOLID:
|
case GDI_BS_SOLID:
|
||||||
color = hbr->color;
|
{
|
||||||
|
const UINT32 color = hbr->color;
|
||||||
|
|
||||||
for (INT32 x = 0; x < nWidth; x++)
|
for (INT32 x = 0; x < nWidth; x++)
|
||||||
{
|
{
|
||||||
@@ -165,21 +162,28 @@ BOOL gdi_FillRect(HGDI_DC hdc, const GDI_RECT* rect, HGDI_BRUSH hbr)
|
|||||||
FreeRDPWriteColor(dstp, hdc->format, color);
|
FreeRDPWriteColor(dstp, hdc->format, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
srcp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest);
|
const BYTE* srcp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest);
|
||||||
formatSize = FreeRDPGetBytesPerPixel(hdc->format);
|
const UINT32 formatSize = FreeRDPGetBytesPerPixel(hdc->format);
|
||||||
|
if (formatSize == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
for (INT32 y = 1; y < nHeight; y++)
|
for (INT32 y = 1; y < nHeight; y++)
|
||||||
{
|
{
|
||||||
BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest + y);
|
BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest + y);
|
||||||
|
if (!dstp)
|
||||||
|
return FALSE;
|
||||||
memcpy(dstp, srcp, 1ull * WINPR_ASSERTING_INT_CAST(size_t, nWidth) * formatSize);
|
memcpy(dstp, srcp, 1ull * WINPR_ASSERTING_INT_CAST(size_t, nWidth) * formatSize);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDI_BS_HATCHED:
|
case GDI_BS_HATCHED:
|
||||||
case GDI_BS_PATTERN:
|
case GDI_BS_PATTERN:
|
||||||
monochrome = (hbr->pattern->format == PIXEL_FORMAT_MONO);
|
{
|
||||||
formatSize = FreeRDPGetBytesPerPixel(hbr->pattern->format);
|
const BOOL monochrome = (hbr->pattern->format == PIXEL_FORMAT_MONO);
|
||||||
|
const UINT32 formatSize = FreeRDPGetBytesPerPixel(hbr->pattern->format);
|
||||||
|
if (formatSize == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
for (INT32 y = 0; y < nHeight; y++)
|
for (INT32 y = 0; y < nHeight; y++)
|
||||||
{
|
{
|
||||||
@@ -197,6 +201,7 @@ BOOL gdi_FillRect(HGDI_DC hdc, const GDI_RECT* rect, HGDI_BRUSH hbr)
|
|||||||
formatSize;
|
formatSize;
|
||||||
const BYTE* patp = &hbr->pattern->data[yOffset + xOffset];
|
const BYTE* patp = &hbr->pattern->data[yOffset + xOffset];
|
||||||
|
|
||||||
|
UINT32 dstColor = 0;
|
||||||
if (monochrome)
|
if (monochrome)
|
||||||
{
|
{
|
||||||
if (*patp == 0)
|
if (*patp == 0)
|
||||||
@@ -206,9 +211,9 @@ BOOL gdi_FillRect(HGDI_DC hdc, const GDI_RECT* rect, HGDI_BRUSH hbr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dstColor = FreeRDPReadColor(patp, hbr->pattern->format);
|
const UINT32 tmp = FreeRDPReadColor(patp, hbr->pattern->format);
|
||||||
dstColor =
|
dstColor =
|
||||||
FreeRDPConvertColor(dstColor, hbr->pattern->format, hdc->format, NULL);
|
FreeRDPConvertColor(tmp, hbr->pattern->format, hdc->format, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x, nYDest + y);
|
BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x, nYDest + y);
|
||||||
@@ -216,8 +221,8 @@ BOOL gdi_FillRect(HGDI_DC hdc, const GDI_RECT* rect, HGDI_BRUSH hbr)
|
|||||||
FreeRDPWriteColor(dstp, hdc->format, dstColor);
|
FreeRDPWriteColor(dstp, hdc->format, dstColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user