22 #include <freerdp/config.h>
28 #include <freerdp/freerdp.h>
29 #include <freerdp/gdi/gdi.h>
31 #include <freerdp/gdi/bitmap.h>
32 #include <freerdp/gdi/region.h>
33 #include <freerdp/gdi/shape.h>
35 #include <freerdp/log.h>
38 #include "../gdi/gdi.h"
40 #define TAG FREERDP_TAG("gdi.shape")
42 static void Ellipse_Bresenham(
HGDI_DC hdc,
int x1,
int y1,
int x2,
int y2)
51 a = (x1 < x2) ? x2 - x1 : x1 - x2;
52 b = (y1 < y2) ? y2 - y1 : y1 - y2;
54 dx = 4 * (1 - a) * b * b;
55 dy = 4 * (c + 1) * a * a;
56 e = dx + dy + c * a * a;
74 gdi_SetPixel(hdc, WINPR_ASSERTING_INT_CAST(UINT32, x2),
75 WINPR_ASSERTING_INT_CAST(UINT32, y1), 0);
76 gdi_SetPixel(hdc, WINPR_ASSERTING_INT_CAST(UINT32, x1),
77 WINPR_ASSERTING_INT_CAST(UINT32, y1), 0);
78 gdi_SetPixel(hdc, WINPR_ASSERTING_INT_CAST(UINT32, x1),
79 WINPR_ASSERTING_INT_CAST(UINT32, y2), 0);
80 gdi_SetPixel(hdc, WINPR_ASSERTING_INT_CAST(UINT32, x2),
81 WINPR_ASSERTING_INT_CAST(UINT32, y2), 0);
104 gdi_SetPixel(hdc, WINPR_ASSERTING_INT_CAST(uint32_t, x1 - 1),
105 WINPR_ASSERTING_INT_CAST(uint32_t, y1), 0);
106 gdi_SetPixel(hdc, WINPR_ASSERTING_INT_CAST(uint32_t, x1 - 1),
107 WINPR_ASSERTING_INT_CAST(uint32_t, y2), 0);
123 BOOL gdi_Ellipse(
HGDI_DC hdc,
int nLeftRect,
int nTopRect,
int nRightRect,
int nBottomRect)
125 Ellipse_Bresenham(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
144 BOOL monochrome = FALSE;
149 const BYTE* srcp = NULL;
150 DWORD formatSize = 0;
151 gdi_RectToCRgn(rect, &nXDest, &nYDest, &nWidth, &nHeight);
156 if (!gdi_ClipCoords(hdc, &nXDest, &nYDest, &nWidth, &nHeight, NULL, NULL))
164 for (INT32 x = 0; x < nWidth; x++)
166 BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x, nYDest);
169 FreeRDPWriteColor(dstp, hdc->format, color);
172 srcp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest);
173 formatSize = FreeRDPGetBytesPerPixel(hdc->format);
175 for (INT32 y = 1; y < nHeight; y++)
177 BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest + y);
178 memcpy(dstp, srcp, 1ull * WINPR_ASSERTING_INT_CAST(
size_t, nWidth) * formatSize);
185 monochrome = (hbr->pattern->format == PIXEL_FORMAT_MONO);
186 formatSize = FreeRDPGetBytesPerPixel(hbr->pattern->format);
188 for (INT32 y = 0; y < nHeight; y++)
190 for (INT32 x = 0; x < nWidth; x++)
192 const size_t yOffset =
193 ((1ULL * WINPR_ASSERTING_INT_CAST(
size_t, nYDest) +
194 WINPR_ASSERTING_INT_CAST(
size_t, y)) *
195 WINPR_ASSERTING_INT_CAST(
size_t, hbr->pattern->width) %
196 WINPR_ASSERTING_INT_CAST(
size_t, hbr->pattern->height)) *
198 const size_t xOffset = ((1ULL * WINPR_ASSERTING_INT_CAST(
size_t, nXDest) +
199 WINPR_ASSERTING_INT_CAST(
size_t, x)) %
200 WINPR_ASSERTING_INT_CAST(
size_t, hbr->pattern->width)) *
202 const BYTE* patp = &hbr->pattern->data[yOffset + xOffset];
207 dstColor = hdc->bkColor;
209 dstColor = hdc->textColor;
213 dstColor = FreeRDPReadColor(patp, hbr->pattern->format);
215 FreeRDPConvertColor(dstColor, hbr->pattern->format, hdc->format, NULL);
218 BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x, nYDest + y);
220 FreeRDPWriteColor(dstp, hdc->format, dstColor);
230 if (!gdi_InvalidateRegion(hdc, nXDest, nYDest, nWidth, nHeight))
246 WLog_ERR(TAG,
"Not implemented!");
259 BOOL gdi_PolyPolygon(
HGDI_DC hdc,
GDI_POINT* lpPoints,
int* lpPolyCounts,
int nCount)
261 WLog_ERR(TAG,
"Not implemented!");
265 BOOL gdi_Rectangle(
HGDI_DC hdc, INT32 nXDst, INT32 nYDst, INT32 nWidth, INT32 nHeight)
269 if (!gdi_ClipCoords(hdc, &nXDst, &nYDst, &nWidth, &nHeight, NULL, NULL))
272 color = hdc->textColor;
274 for (INT32 y = 0; y < nHeight; y++)
276 BYTE* dstLeft = gdi_get_bitmap_pointer(hdc, nXDst, nYDst + y);
277 BYTE* dstRight = gdi_get_bitmap_pointer(hdc, nXDst + nWidth - 1, nYDst + y);
280 FreeRDPWriteColor(dstLeft, hdc->format, color);
283 FreeRDPWriteColor(dstRight, hdc->format, color);
286 for (INT32 x = 0; x < nWidth; x++)
288 BYTE* dstTop = gdi_get_bitmap_pointer(hdc, nXDst + x, nYDst);
289 BYTE* dstBottom = gdi_get_bitmap_pointer(hdc, nXDst + x, nYDst + nHeight - 1);
292 FreeRDPWriteColor(dstTop, hdc->format, color);
295 FreeRDPWriteColor(dstBottom, hdc->format, color);