22 HGDI_BITMAP test_convert_to_bitmap(
const BYTE* src, UINT32 SrcFormat, UINT32 SrcStride, UINT32 xSrc,
23 UINT32 ySrc, UINT32 DstFormat, UINT32 DstStride, UINT32 xDst,
24 UINT32 yDst, UINT32 nWidth, UINT32 nHeight,
25 const gdiPalette* hPalette)
31 DstStride = nWidth * FreeRDPGetBytesPerPixel(DstFormat);
33 data = winpr_aligned_malloc(1ULL * DstStride * nHeight, 16);
38 if (!freerdp_image_copy(data, DstFormat, DstStride, xDst, yDst, nWidth, nHeight, src, SrcFormat,
39 SrcStride, xSrc, ySrc, hPalette, FREERDP_FLIP_NONE))
41 winpr_aligned_free(data);
45 bmp = gdi_CreateBitmap(nWidth, nHeight, DstFormat, data);
49 winpr_aligned_free(data);
56 static void test_dump_data(
unsigned char* p,
int len,
int width,
const char* name)
58 unsigned char* line = p;
61 printf(
"\n%s[%d][%d]:\n", name, len / width, width);
66 printf(
"%04x ", offset);
67 thisline = len - offset;
72 for (; i < thisline; i++)
73 printf(
"%02x ", line[i]);
75 for (; i < width; i++)
87 void test_dump_bitmap(
HGDI_BITMAP hBmp,
const char* name)
89 UINT32 stride = hBmp->width * FreeRDPGetBytesPerPixel(hBmp->format);
90 test_dump_data(hBmp->data, hBmp->height * stride, stride, name);
95 const BYTE* p1 = hBmp1->data;
96 const BYTE* p2 = hBmp2->data;
97 const UINT32 minw = (hBmp1->width < hBmp2->width) ? hBmp1->width : hBmp2->width;
98 const UINT32 minh = (hBmp1->height < hBmp2->height) ? hBmp1->height : hBmp2->height;
100 for (UINT32 y = 0; y < minh; y++)
102 for (UINT32 x = 0; x < minw; x++)
104 UINT32 colorA = FreeRDPReadColor(p1, hBmp1->format);
105 UINT32 colorB = FreeRDPReadColor(p2, hBmp2->format);
106 p1 += FreeRDPGetBytesPerPixel(hBmp1->format);
107 p2 += FreeRDPGetBytesPerPixel(hBmp2->format);
109 if (hBmp1->format != hBmp2->format)
110 colorB = FreeRDPConvertColor(colorB, hBmp2->format, hBmp1->format, palette);
112 if (colorA != colorB)
121 const gdiPalette* palette)
123 BOOL bitmapsEqual = CompareBitmaps(hBmpActual, hBmpExpected, palette);
127 printf(
"Testing ROP %s [%s|%s]\n", name, FreeRDPGetColorFormatName(hBmpActual->format),
128 FreeRDPGetColorFormatName(hBmpExpected->format));
129 test_dump_bitmap(hBmpActual,
"Actual");
130 test_dump_bitmap(hBmpExpected,
"Expected");
131 (void)fflush(stdout);
132 (void)fflush(stderr);