4#include <winpr/image.h>
5#include <freerdp/codec/color.h>
9static BOOL run_testcase(
size_t x,
const gdiPalette* palette,
const rdpPointer* pointer,
12 WINPR_ASSERT(palette);
13 WINPR_ASSERT(pointer);
16 WLog_INFO(
"test",
"running cursor test case %" PRIuz, x);
18 const uint32_t format = PIXEL_FORMAT_BGRA32;
19 const size_t width = pointer->width;
20 const size_t height = pointer->height;
21 const size_t xorBpp = pointer->xorBpp;
22 const size_t bpp = FreeRDPGetBytesPerPixel(format);
23 const size_t stride = width * bpp;
25 uint8_t* bmp = calloc(stride, height);
29 const BOOL result = freerdp_image_copy_from_pointer_data(
30 bmp, format, 0, 0, 0, width, height, pointer->xorMaskData, pointer->lengthXorMask,
31 pointer->andMaskData, pointer->lengthAndMask, xorBpp, palette);
36 for (
size_t y = 0; y < height; y++)
38 const uint8_t* linea = &bmp[y * stride];
39 const uint8_t* lineb = &ref[y * stride];
40 for (
size_t x = 0; x < stride; x++)
42 const uint8_t a = linea[x];
43 const uint8_t b = lineb[x];
46 printf(
"xxx: %" PRIuz
"x%" PRIuz
": color %" PRIuz
" diff 0x%02" PRIx8
47 "<-->0x%02" PRIx8
"\n",
48 x / 4, y, x % 4, a, b);
56 WLog_INFO(
"test",
"cursor test case %" PRIuz
": %s", x, rc ?
"success" :
"failure");
60int TestFreeRDPCodecCursor(WINPR_ATTR_UNUSED
int argc, WINPR_ATTR_UNUSED
char* argv[])
62 const size_t palette_len = ARRAYSIZE(testcase_palette);
63 const size_t pointer_len = ARRAYSIZE(testcase_pointer);
64 const size_t bmp_len = ARRAYSIZE(testcase_image_bgra32);
65 WINPR_ASSERT(palette_len == pointer_len);
66 WINPR_ASSERT(palette_len == bmp_len);
69 for (
size_t x = 0; x < palette_len; x++)
71 const gdiPalette* palette = testcase_palette[x];
72 const rdpPointer* pointer = testcase_pointer[x];
73 const uint8_t* bmp = testcase_image_bgra32[x];
75 if (!run_testcase(x, palette, pointer, bmp))