2 #include <freerdp/gdi/gdi.h>
4 #include <freerdp/gdi/dc.h>
5 #include <freerdp/gdi/pen.h>
6 #include <freerdp/gdi/shape.h>
7 #include <freerdp/gdi/region.h>
8 #include <freerdp/gdi/bitmap.h>
10 #include <winpr/crt.h>
11 #include <winpr/print.h>
17 static int test_gdi_PtInRect(
void)
26 if (!(hRect = gdi_CreateRect(left, top, right, bottom)))
28 printf(
"gdi_CreateRect failed\n");
32 if (gdi_PtInRect(hRect, 0, 0))
35 if (gdi_PtInRect(hRect, 500, 500))
38 if (gdi_PtInRect(hRect, 40, 100))
41 if (gdi_PtInRect(hRect, 10, 40))
44 if (!gdi_PtInRect(hRect, 30, 50))
47 if (!gdi_PtInRect(hRect, left, top))
50 if (!gdi_PtInRect(hRect, right, bottom))
53 if (!gdi_PtInRect(hRect, right, 60))
56 if (!gdi_PtInRect(hRect, 40, bottom))
65 static int test_gdi_FillRect(
void)
76 UINT32 goodPixels = 0;
84 if (!(hdc = gdi_GetDC()))
86 printf(
"failed to get gdi device context\n");
90 hdc->format = PIXEL_FORMAT_XRGB32;
92 if (!(hRect = gdi_CreateRect(left, top, right, bottom)))
94 printf(
"gdi_CreateRect failed\n");
98 hBitmap = gdi_CreateCompatibleBitmap(hdc, width, height);
99 ZeroMemory(hBitmap->data, 1ULL * width * height * FreeRDPGetBytesPerPixel(hdc->format));
101 color = FreeRDPGetColor(PIXEL_FORMAT_ARGB32, 0xAA, 0xBB, 0xCC, 0xFF);
102 hBrush = gdi_CreateSolidBrush(color);
103 gdi_FillRect(hdc, hRect, hBrush);
107 for (UINT32 x = 0; x < width; x++)
109 for (UINT32 y = 0; y < height; y++)
111 rawPixel = gdi_GetPixel(hdc, x, y);
112 pixel = FreeRDPConvertColor(rawPixel, hdc->format, PIXEL_FORMAT_ARGB32, NULL);
114 if (gdi_PtInRect(hRect, x, y))
122 printf(
"actual:%08" PRIX32
" expected:%08" PRIX32
"\n", gdi_GetPixel(hdc, x, y),
141 if (goodPixels != width * height)
156 int TestGdiRect(
int argc,
char* argv[])
161 if (test_gdi_PtInRect() < 0)
164 if (test_gdi_FillRect() < 0)