gdi: Add a simple test for bitmap bits/metrics
Add a simple test for bitmap bits/metrics, fix GetBitmapBits for an empty (not selected into a DC) bitmap.
This commit is contained in:
parent
5052dcccf2
commit
5c1b27a029
|
@ -366,8 +366,9 @@ LONG WINAPI GetBitmapBits(
|
|||
} else {
|
||||
|
||||
if(!bmp->bitmap.bmBits) {
|
||||
WARN("Bitmap is empty\n");
|
||||
ret = 0;
|
||||
TRACE("Bitmap is empty\n");
|
||||
memset(bits, 0, count);
|
||||
ret = count;
|
||||
} else {
|
||||
memcpy(bits, bmp->bitmap.bmBits, count);
|
||||
ret = count;
|
||||
|
|
|
@ -982,10 +982,91 @@ else
|
|||
}
|
||||
}
|
||||
|
||||
static void test_bitmap(void)
|
||||
{
|
||||
char buf[256], buf_cmp[256];
|
||||
HBITMAP hbmp, hbmp_old;
|
||||
HDC hdc;
|
||||
BITMAP bm;
|
||||
INT ret;
|
||||
|
||||
hdc = CreateCompatibleDC(0);
|
||||
assert(hdc != 0);
|
||||
|
||||
hbmp = CreateBitmap(15, 15, 1, 1, NULL);
|
||||
assert(hbmp != NULL);
|
||||
|
||||
ret = GetObject(hbmp, sizeof(bm), &bm);
|
||||
ok(ret == sizeof(bm), "%d != %d\n", ret, sizeof(bm));
|
||||
|
||||
ok(bm.bmType == 0, "wrong bm.bmType %d\n", bm.bmType);
|
||||
ok(bm.bmWidth == 15, "wrong bm.bmWidth %d\n", bm.bmWidth);
|
||||
ok(bm.bmHeight == 15, "wrong bm.bmHeight %d\n", bm.bmHeight);
|
||||
ok(bm.bmWidthBytes == 2, "wrong bm.bmWidthBytes %d\n", bm.bmWidthBytes);
|
||||
ok(bm.bmPlanes == 1, "wrong bm.bmPlanes %d\n", bm.bmPlanes);
|
||||
ok(bm.bmBitsPixel == 1, "wrong bm.bmBitsPixel %d\n", bm.bmBitsPixel);
|
||||
ok(bm.bmBits == NULL, "wrong bm.bmBits %p\n", bm.bmBits);
|
||||
|
||||
assert(sizeof(buf) >= bm.bmWidthBytes * bm.bmHeight);
|
||||
assert(sizeof(buf) == sizeof(buf_cmp));
|
||||
|
||||
memset(buf_cmp, 0xAA, sizeof(buf_cmp));
|
||||
memset(buf_cmp, 0, bm.bmWidthBytes * bm.bmHeight);
|
||||
|
||||
memset(buf, 0xAA, sizeof(buf));
|
||||
ret = GetBitmapBits(hbmp, sizeof(buf), buf);
|
||||
ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
|
||||
ok(!memcmp(buf, buf_cmp, sizeof(buf)), "buffers do not match\n");
|
||||
|
||||
hbmp_old = SelectObject(hdc, hbmp);
|
||||
|
||||
ret = GetObject(hbmp, sizeof(bm), &bm);
|
||||
ok(ret == sizeof(bm), "%d != %d\n", ret, sizeof(bm));
|
||||
|
||||
ok(bm.bmType == 0, "wrong bm.bmType %d\n", bm.bmType);
|
||||
ok(bm.bmWidth == 15, "wrong bm.bmWidth %d\n", bm.bmWidth);
|
||||
ok(bm.bmHeight == 15, "wrong bm.bmHeight %d\n", bm.bmHeight);
|
||||
ok(bm.bmWidthBytes == 2, "wrong bm.bmWidthBytes %d\n", bm.bmWidthBytes);
|
||||
ok(bm.bmPlanes == 1, "wrong bm.bmPlanes %d\n", bm.bmPlanes);
|
||||
ok(bm.bmBitsPixel == 1, "wrong bm.bmBitsPixel %d\n", bm.bmBitsPixel);
|
||||
ok(bm.bmBits == NULL, "wrong bm.bmBits %p\n", bm.bmBits);
|
||||
|
||||
memset(buf, 0xAA, sizeof(buf));
|
||||
ret = GetBitmapBits(hbmp, sizeof(buf), buf);
|
||||
ok(ret == bm.bmWidthBytes * bm.bmHeight, "%d != %d\n", ret, bm.bmWidthBytes * bm.bmHeight);
|
||||
todo_wine {
|
||||
ok(!memcmp(buf, buf_cmp, sizeof(buf)), "buffers do not match\n");
|
||||
}
|
||||
|
||||
hbmp_old = SelectObject(hdc, hbmp_old);
|
||||
ok(hbmp_old == hbmp, "wrong old bitmap %p\n", hbmp_old);
|
||||
|
||||
/* test various buffer sizes for GetObject */
|
||||
ret = GetObject(hbmp, sizeof(bm) * 2, &bm);
|
||||
ok(ret == sizeof(bm), "%d != %d\n", ret, sizeof(bm));
|
||||
|
||||
ret = GetObject(hbmp, sizeof(bm) / 2, &bm);
|
||||
todo_wine {
|
||||
ok(ret == 0, "%d != 0\n", ret);
|
||||
}
|
||||
|
||||
ret = GetObject(hbmp, 0, &bm);
|
||||
ok(ret == 0, "%d != 0\n", ret);
|
||||
|
||||
ret = GetObject(hbmp, 1, &bm);
|
||||
todo_wine {
|
||||
ok(ret == 0, "%d != 0\n", ret);
|
||||
}
|
||||
|
||||
DeleteObject(hbmp);
|
||||
DeleteDC(hdc);
|
||||
}
|
||||
|
||||
START_TEST(gdiobj)
|
||||
{
|
||||
test_logfont();
|
||||
test_logpen();
|
||||
test_bitmap();
|
||||
test_bitmap_font();
|
||||
test_bitmap_font_metrics();
|
||||
test_gdi_objects();
|
||||
|
|
Loading…
Reference in New Issue