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, x2, y1, 0);
75 gdi_SetPixel(hdc, x1, y1, 0);
76 gdi_SetPixel(hdc, x1, y2, 0);
77 gdi_SetPixel(hdc, x2, y2, 0);
97 gdi_SetPixel(hdc, x1 - 1, ++y1, 0);
98 gdi_SetPixel(hdc, x1 - 1, --y2, 0);
114 BOOL gdi_Ellipse(
HGDI_DC hdc,
int nLeftRect,
int nTopRect,
int nRightRect,
int nBottomRect)
116 Ellipse_Bresenham(hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
135 BOOL monochrome = FALSE;
140 const BYTE* srcp = NULL;
141 DWORD formatSize = 0;
142 gdi_RectToCRgn(rect, &nXDest, &nYDest, &nWidth, &nHeight);
147 if (!gdi_ClipCoords(hdc, &nXDest, &nYDest, &nWidth, &nHeight, NULL, NULL))
155 for (INT32 x = 0; x < nWidth; x++)
157 BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x, nYDest);
160 FreeRDPWriteColor(dstp, hdc->format, color);
163 srcp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest);
164 formatSize = FreeRDPGetBytesPerPixel(hdc->format);
166 for (INT32 y = 1; y < nHeight; y++)
168 BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest, nYDest + y);
169 memcpy(dstp, srcp, 1ull * nWidth * formatSize);
176 monochrome = (hbr->pattern->format == PIXEL_FORMAT_MONO);
177 formatSize = FreeRDPGetBytesPerPixel(hbr->pattern->format);
179 for (INT32 y = 0; y < nHeight; y++)
181 for (INT32 x = 0; x < nWidth; x++)
183 const size_t yOffset =
184 ((1ULL * nYDest + y) * hbr->pattern->width % hbr->pattern->height) *
186 const size_t xOffset = ((1ULL * nXDest + x) % hbr->pattern->width) * formatSize;
187 const BYTE* patp = &hbr->pattern->data[yOffset + xOffset];
192 dstColor = hdc->bkColor;
194 dstColor = hdc->textColor;
198 dstColor = FreeRDPReadColor(patp, hbr->pattern->format);
200 FreeRDPConvertColor(dstColor, hbr->pattern->format, hdc->format, NULL);
203 BYTE* dstp = gdi_get_bitmap_pointer(hdc, nXDest + x, nYDest + y);
205 FreeRDPWriteColor(dstp, hdc->format, dstColor);
215 if (!gdi_InvalidateRegion(hdc, nXDest, nYDest, nWidth, nHeight))
231 WLog_ERR(TAG,
"Not implemented!");
244 BOOL gdi_PolyPolygon(
HGDI_DC hdc,
GDI_POINT* lpPoints,
int* lpPolyCounts,
int nCount)
246 WLog_ERR(TAG,
"Not implemented!");
250 BOOL gdi_Rectangle(
HGDI_DC hdc, INT32 nXDst, INT32 nYDst, INT32 nWidth, INT32 nHeight)
254 if (!gdi_ClipCoords(hdc, &nXDst, &nYDst, &nWidth, &nHeight, NULL, NULL))
257 color = hdc->textColor;
259 for (INT32 y = 0; y < nHeight; y++)
261 BYTE* dstLeft = gdi_get_bitmap_pointer(hdc, nXDst, nYDst + y);
262 BYTE* dstRight = gdi_get_bitmap_pointer(hdc, nXDst + nWidth - 1, nYDst + y);
265 FreeRDPWriteColor(dstLeft, hdc->format, color);
268 FreeRDPWriteColor(dstRight, hdc->format, color);
271 for (INT32 x = 0; x < nWidth; x++)
273 BYTE* dstTop = gdi_get_bitmap_pointer(hdc, nXDst + x, nYDst);
274 BYTE* dstBottom = gdi_get_bitmap_pointer(hdc, nXDst + x, nYDst + nHeight - 1);
277 FreeRDPWriteColor(dstTop, hdc->format, color);
280 FreeRDPWriteColor(dstBottom, hdc->format, color);