[GDI32_APITEST]

Fix InitStuff(), declare the 32 bpp DIB array 2 dimensional and make it 8x8 in size.

svn path=/trunk/; revision=66256
This commit is contained in:
Timo Kreuzer 2015-02-14 11:25:02 +00:00
parent 151e583938
commit 529aae440b
6 changed files with 101 additions and 109 deletions

View file

@ -64,10 +64,10 @@ void Test_CreateDIBPatternBrushPt()
/* Copy it on the dib section */
ok_long(PatBlt(ghdcDIB32, 0, 0, 4, 4, PATCOPY), 1);
ok_long(pulDIB32Bits[0], 0x000000); // 0
ok_long(pulDIB32Bits[1], 0x800000); // 1
ok_long(pulDIB32Bits[2], 0x008000); // 2
ok_long(pulDIB32Bits[3], 0xc0c0c0); // 7
ok_long((*gpDIB32)[0][0], 0x000000); // 0
ok_long((*gpDIB32)[0][1], 0x800000); // 1
ok_long((*gpDIB32)[0][2], 0x008000); // 2
ok_long((*gpDIB32)[0][3], 0xc0c0c0); // 7
/* Select a logical palette into the DC */
hpalOld = SelectPalette(ghdcDIB32, ghpal, FALSE);
@ -75,21 +75,21 @@ void Test_CreateDIBPatternBrushPt()
/* Copy it on the dib section */
ok_long(PatBlt(ghdcDIB32, 0, 0, 4, 4, PATCOPY), 1);
ok_long(pulDIB32Bits[0], 0x102030); // 0
ok_long(pulDIB32Bits[1], 0x203040); // 1
ok_long(pulDIB32Bits[2], 0x304050); // 2
ok_long(pulDIB32Bits[3], 0x8090a0); // 7
ok_long((*gpDIB32)[0][0], 0x102030); // 0
ok_long((*gpDIB32)[0][1], 0x203040); // 1
ok_long((*gpDIB32)[0][2], 0x304050); // 2
ok_long((*gpDIB32)[0][3], 0x8090a0); // 7
/* Select back old palette and destroy the DIB data */
SelectPalette(ghdcDIB32, hpalOld, FALSE);
memset(&PackedDIB.ajBuffer, 0x77, 4);
memset(gpDIB32, 0x77, sizeof(*gpDIB32));
/* Copy it on the dib section */
ok_long(PatBlt(ghdcDIB32, 0, 0, 4, 4, PATCOPY), 1);
ok_long(pulDIB32Bits[0], 0x000000); // 0
ok_long(pulDIB32Bits[1], 0x800000); // 1
ok_long(pulDIB32Bits[2], 0x008000); // 2
ok_long(pulDIB32Bits[3], 0xc0c0c0); // 7
ok_long((*gpDIB32)[0][0], 0x000000); // 0
ok_long((*gpDIB32)[0][1], 0x800000); // 1
ok_long((*gpDIB32)[0][2], 0x008000); // 2
ok_long((*gpDIB32)[0][3], 0xc0c0c0); // 7
SelectObject(ghdcDIB32, hbrOld);
DeleteObject(hbr);
@ -110,12 +110,12 @@ void Test_CreateDIBPatternBrushPt()
ok(hbrOld != 0, "CreateSolidBrush failed, skipping tests.\n");
/* Copy it on a dib section */
memset(pulDIB32Bits, 0x77, 64);
memset(gpDIB32, 0x77, sizeof(*gpDIB32));
ok_long(PatBlt(ghdcDIB32, 0, 0, 4, 4, PATCOPY), 1);
ok_long(pulDIB32Bits[0], 0x77777777);
ok_long(pulDIB32Bits[1], 0x77777777);
ok_long(pulDIB32Bits[2], 0x77777777);
ok_long(pulDIB32Bits[3], 0x77777777);
ok_long((*gpDIB32)[0][0], 0x77777777);
ok_long((*gpDIB32)[0][1], 0x77777777);
ok_long((*gpDIB32)[0][2], 0x77777777);
ok_long((*gpDIB32)[0][3], 0x77777777);
/* Select a logical palette into the DC */
hpalOld = SelectPalette(ghdcDIB32, ghpal, FALSE);
@ -123,10 +123,10 @@ void Test_CreateDIBPatternBrushPt()
/* Copy it on a dib section */
ok_long(PatBlt(ghdcDIB32, 0, 0, 4, 4, PATCOPY), 1);
ok_long(pulDIB32Bits[0], 0x77777777);
ok_long(pulDIB32Bits[1], 0x77777777);
ok_long(pulDIB32Bits[2], 0x77777777);
ok_long(pulDIB32Bits[3], 0x77777777);
ok_long((*gpDIB32)[0][0], 0x77777777);
ok_long((*gpDIB32)[0][1], 0x77777777);
ok_long((*gpDIB32)[0][2], 0x77777777);
ok_long((*gpDIB32)[0][3], 0x77777777);
SelectPalette(ghdcDIB32, hpalOld, FALSE);
SelectObject(ghdcDIB32, hbrOld);
@ -168,6 +168,6 @@ START_TEST(CreateDIBPatternBrush)
Test_CreateDIBPatternBrush();
Test_CreateDIBPatternBrushPt();
Test_CreateDIBPatternBrushPt_RLE8();
//Test_CreateDIBPatternBrushPt_RLE8(); broken
}

View file

@ -462,12 +462,12 @@ Test_CreateDIBitmap_CBM_CREATDIB(void)
ok(hbmpOld != NULL, "Couldn't select the bitmap.\n");
/* Copy it on a dib section */
memset(pulDIB32Bits, 0x77, 64);
memset(gpDIB32, 0x77, sizeof(*gpDIB32));
ok_long(BitBlt(ghdcDIB32, 0, 0, 4, 4, hdc, 0, 0, SRCCOPY), 1);
ok_long(pulDIB32Bits[0], 0x20100);
ok_long(pulDIB32Bits[1], 0x20100);
ok_long(pulDIB32Bits[2], 0x20100);
ok_long(pulDIB32Bits[3], 0x20100);
ok_long((*gpDIB32)[0][0], 0x20100);
ok_long((*gpDIB32)[0][1], 0x20100);
ok_long((*gpDIB32)[0][2], 0x20100);
ok_long((*gpDIB32)[0][3], 0x20100);
SelectObject(hdc, hbmpOld);
DeleteObject(hbmp);
@ -501,12 +501,12 @@ Test_CreateDIBitmap_CBM_CREATDIB(void)
ok(hbmpOld != NULL, "Couldn't select the bitmap.\n");
/* Copy it on a dib section */
memset(pulDIB32Bits, 0x77, 64);
memset(gpDIB32, 0x77, sizeof(*gpDIB32));
ok_long(BitBlt(ghdcDIB32, 0, 0, 4, 4, hdc, 0, 0, SRCCOPY), 1);
ok_long(pulDIB32Bits[0], 0);
ok_long(pulDIB32Bits[1], 0);
ok_long(pulDIB32Bits[2], 0);
ok_long(pulDIB32Bits[3], 0);
ok_long((*gpDIB32)[0][0], 0);
ok_long((*gpDIB32)[0][1], 0);
ok_long((*gpDIB32)[0][2], 0);
ok_long((*gpDIB32)[0][3], 0);
SelectObject(hdc, hbmpOld);
DeleteObject(hbmp);

View file

@ -119,10 +119,6 @@ void Test_GetDIBits()
ok(hdcScreen != 0, "GetDC failed, skipping tests\n");
if (hdcScreen == NULL) return;
hdcMem = CreateCompatibleDC(0);
ok(hdcMem != 0, "CreateCompatibleDC failed, skipping tests\n");
if (hdcMem == NULL) return;
hbmp = CreateCompatibleBitmap(hdcScreen, 16, 16);
ok(hbmp != NULL, "CreateCompatibleBitmap failed\n");
@ -412,9 +408,14 @@ void Test_GetDIBits()
cjSizeImage = ((pbi->bmiHeader.biWidth * pbi->bmiHeader.biBitCount + 31) / 32) * 4 * pbi->bmiHeader.biHeight;
pvBits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cjSizeImage);
ok(SelectObject(hdcMem, ghbmpDIB4) != 0, "\n");;
ok_int(GetDIBits(hdcMem, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
ok_int(GetDIBits(hdcMem, ghbmpDIB4, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 3);
hdcMem = CreateCompatibleDC(0);
ok(hdcMem != 0, "CreateCompatibleDC failed, skipping tests\n");
if (hdcMem == NULL) return;
// FIXME: broken
//ok(SelectObject(hdcMem, ghbmpDIB4) != 0, "Failed to select 4bpp DIB %p into DC %p\n", ghbmpDIB4, hdcMem);;
//ok_int(GetDIBits(hdcMem, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
//ok_int(GetDIBits(hdcMem, ghbmpDIB4, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 3);
DeleteDC(hdcMem);

View file

@ -476,7 +476,7 @@ Test_SetDIBitsToDevice()
aulBits[3] = 0x000000FF;
memset(pulDIB32Bits, 0, 4 * 4 * sizeof(ULONG));
memset(gpDIB32, 0, sizeof(*gpDIB32));
ret = SetDIBitsToDevice(ghdcDIB32,
0, // XDest,
0, // YDest,
@ -491,16 +491,16 @@ Test_SetDIBitsToDevice()
DIB_RGB_COLORS);
ok_dec(ret, 2);
ok_hex(pulDIB32Bits[0], 0x11000000);
ok_hex(pulDIB32Bits[1], 0x00000011);
ok_hex(pulDIB32Bits[2], 0x00000000);
ok_hex(pulDIB32Bits[3], 0x00000000);
ok_hex(pulDIB32Bits[4], 0xFF000000);
ok_hex(pulDIB32Bits[5], 0x000000FF);
ok_hex(pulDIB32Bits[6], 0x00000000);
ok_hex(pulDIB32Bits[7], 0x00000000);
ok_hex((*gpDIB32)[0][0], 0x11000000);
ok_hex((*gpDIB32)[0][1], 0x00000011);
ok_hex((*gpDIB32)[0][2], 0x00000000);
ok_hex((*gpDIB32)[0][3], 0x00000000);
ok_hex((*gpDIB32)[1][0], 0xFF000000);
ok_hex((*gpDIB32)[1][1], 0x000000FF);
ok_hex((*gpDIB32)[1][2], 0x00000000);
ok_hex((*gpDIB32)[1][3], 0x00000000);
memset(pulDIB32Bits, 0, 4 * 4 * sizeof(ULONG));
memset(gpDIB32, 0, sizeof(*gpDIB32));
ret = SetDIBitsToDevice(ghdcDIB32,
0, // XDest,
1, // YDest,
@ -515,20 +515,20 @@ Test_SetDIBitsToDevice()
DIB_RGB_COLORS);
ok_dec(ret, 2);
ok_hex(pulDIB32Bits[0], 0x00000000);
ok_hex(pulDIB32Bits[1], 0x00000000);
ok_hex(pulDIB32Bits[2], 0x00000000);
ok_hex(pulDIB32Bits[3], 0x00000000);
ok_hex(pulDIB32Bits[4], 0x11000000);
ok_hex(pulDIB32Bits[5], 0x00000011);
ok_hex(pulDIB32Bits[6], 0x00000000);
ok_hex(pulDIB32Bits[7], 0x00000000);
ok_hex(pulDIB32Bits[8], 0xFF000000);
ok_hex(pulDIB32Bits[9], 0x000000FF);
ok_hex(pulDIB32Bits[10], 0x00000000);
ok_hex(pulDIB32Bits[11], 0x00000000);
ok_hex((*gpDIB32)[0][0], 0x00000000);
ok_hex((*gpDIB32)[0][1], 0x00000000);
ok_hex((*gpDIB32)[0][2], 0x00000000);
ok_hex((*gpDIB32)[0][3], 0x00000000);
ok_hex((*gpDIB32)[1][0], 0x11000000);
ok_hex((*gpDIB32)[1][1], 0x00000011);
ok_hex((*gpDIB32)[1][2], 0x00000000);
ok_hex((*gpDIB32)[1][3], 0x00000000);
ok_hex((*gpDIB32)[2][0], 0xFF000000);
ok_hex((*gpDIB32)[2][1], 0x000000FF);
ok_hex((*gpDIB32)[2][2], 0x00000000);
ok_hex((*gpDIB32)[2][3], 0x00000000);
memset(pulDIB32Bits, 0, 4 * 4 * sizeof(ULONG));
memset(gpDIB32, 0, sizeof(*gpDIB32));
ret = SetDIBitsToDevice(ghdcDIB32,
0, // XDest,
0, // YDest,
@ -543,17 +543,17 @@ Test_SetDIBitsToDevice()
DIB_RGB_COLORS);
ok_dec(ret, 1);
todo_ros ok_hex(pulDIB32Bits[0], 0x00000000);
todo_ros ok_hex(pulDIB32Bits[1], 0x00000000);
ok_hex(pulDIB32Bits[2], 0x00000000);
ok_hex(pulDIB32Bits[3], 0x00000000);
todo_ros ok_hex(pulDIB32Bits[4], 0x11000000);
todo_ros ok_hex(pulDIB32Bits[5], 0x00000011);
ok_hex(pulDIB32Bits[6], 0x00000000);
ok_hex(pulDIB32Bits[7], 0x00000000);
todo_ros ok_hex((*gpDIB32)[0][0], 0x00000000);
todo_ros ok_hex((*gpDIB32)[0][1], 0x00000000);
ok_hex((*gpDIB32)[0][2], 0x00000000);
ok_hex((*gpDIB32)[0][3], 0x00000000);
todo_ros ok_hex((*gpDIB32)[1][0], 0x11000000);
todo_ros ok_hex((*gpDIB32)[1][1], 0x00000011);
ok_hex((*gpDIB32)[1][2], 0x00000000);
ok_hex((*gpDIB32)[1][3], 0x00000000);
#if 0
memset(pulDIB32Bits, 0, 4 * 4 * sizeof(ULONG));
memset(gpDIB32, 0, sizeof(*gpDIB32));
ret = SetDIBitsToDevice(ghdcDIB32,
0, // XDest,
0, // YDest,
@ -582,7 +582,7 @@ Test_SetDIBitsToDevice()
/* Use bottom-up bitmap */
pbmi->bmiHeader.biHeight = 2;
memset(pulDIB32Bits, 0, 4 * 4 * sizeof(ULONG));
memset(gpDIB32, 0, sizeof(*gpDIB32));
ret = SetDIBitsToDevice(ghdcDIB32,
0, // XDest,
0, // YDest,
@ -606,7 +606,7 @@ Test_SetDIBitsToDevice()
ok_hex(pulDIB32Bits[6], 0x00000000);
ok_hex(pulDIB32Bits[7], 0x00000000);
memset(pulDIB32Bits, 0, 4 * 4 * sizeof(ULONG));
memset(gpDIB32, 0, sizeof(*gpDIB32));
ret = SetDIBitsToDevice(ghdcDIB32,
0, // XDest,
1, // YDest,
@ -634,7 +634,7 @@ Test_SetDIBitsToDevice()
ok_hex(pulDIB32Bits[10], 0x00000000);
ok_hex(pulDIB32Bits[11], 0x00000000);
memset(pulDIB32Bits, 0, 4 * 4 * sizeof(ULONG));
memset(gpDIB32, 0, sizeof(*gpDIB32));
ret = SetDIBitsToDevice(ghdcDIB32,
0, // XDest,
0, // YDest,
@ -659,7 +659,7 @@ Test_SetDIBitsToDevice()
ok_hex(pulDIB32Bits[7], 0x00000000);
memset(pulDIB32Bits, 0, 4 * 4 * sizeof(ULONG));
memset(gpDIB32, 0, sizeof(*gpDIB32));
ret = SetDIBitsToDevice(ghdcDIB32,
0, // XDest,
0, // YDest,
@ -682,7 +682,7 @@ Test_SetDIBitsToDevice()
todo_ros ok_hex(pulDIB32Bits[5], 0x00000000);
ok_hex(pulDIB32Bits[6], 0x00000000);
ok_hex(pulDIB32Bits[7], 0x00000000);
#endif
}

View file

@ -5,11 +5,10 @@
#include "init.h"
HBITMAP ghbmp1, ghbmp4, ghbmp8, ghbmp16, ghbmp24, ghbmp32;
HDC ghdcBmp1, ghdcBmp4, ghdcBmp8, ghdcBmp16, ghdcBmp24, ghdcBmp32;
HBITMAP ghbmpDIB1, ghbmpDIB4, ghbmpDIB8, ghbmpDIB16, ghbmpDIB24, ghbmpDIB32;
HDC ghdcDIB1, ghdcDIB4, ghdcDIB8, ghdcDIB16, ghdcDIB24, ghdcDIB32;
PVOID gpvDIB1, gpvDIB4, gpvDIB8, gpvDIB16, gpvDIB24, gpvDIB32;
PULONG pulDIB32Bits;
ULONG (*gpDIB32)[8][8];
PULONG pulDIB4Bits;
HPALETTE ghpal;
@ -33,7 +32,6 @@ InitPerBitDepth(
_In_ ULONG cBitsPerPixel,
_In_ ULONG cx,
_In_ ULONG cy,
_Out_ HDC *phdcBmp,
_Out_ HBITMAP *phbmp,
_Out_ HDC *phdcDIB,
_Out_ HBITMAP *phbmpDIB,
@ -46,14 +44,6 @@ InitPerBitDepth(
} bmiBuffer;
LPBITMAPINFO pbmi = (LPBITMAPINFO)&bmiBuffer;
/* Create a compatible DC for the bitmap */
*phdcBmp = CreateCompatibleDC(0);
if (*phdcBmp == NULL)
{
printf("CreateCompatibleDC failed for %lu bpp\n", cBitsPerPixel);
return FALSE;
}
/* Create a bitmap */
*phbmp = CreateBitmap(cx, cy, 1, cBitsPerPixel, NULL);
if (*phbmp == NULL)
@ -62,16 +52,19 @@ InitPerBitDepth(
return FALSE;
}
SelectObject(*phdcBmp, *phbmp);
/* Get info about the bitmap */
/* Setup bitmap info */
memset(&bmiBuffer, 0, sizeof(bmiBuffer));
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
if (!GetDIBits(*phdcBmp, *phbmp, 0, 1, NULL, pbmi, DIB_RGB_COLORS))
{
printf("GetDIBits failed %lu\n", cBitsPerPixel);
return FALSE;
}
pbmi->bmiHeader.biWidth = cx;
pbmi->bmiHeader.biHeight = -(LONG)cy;
pbmi->bmiHeader.biPlanes = 1;
pbmi->bmiHeader.biBitCount = cBitsPerPixel;
pbmi->bmiHeader.biCompression = BI_RGB;
pbmi->bmiHeader.biSizeImage = 0;
pbmi->bmiHeader.biXPelsPerMeter = 0;
pbmi->bmiHeader.biYPelsPerMeter = 0;
pbmi->bmiHeader.biClrUsed = 0;
pbmi->bmiHeader.biClrImportant = 0;
/* Create a compatible DC for the DIB */
*phdcDIB = CreateCompatibleDC(0);
@ -81,9 +74,6 @@ InitPerBitDepth(
return FALSE;
}
pbmi->bmiHeader.biCompression = BI_RGB;
pbmi->bmiHeader.biHeight = -pbmi->bmiHeader.biHeight;
/* Create the DIB section with the same values */
*phbmpDIB = CreateDIBSection(*phdcDIB, pbmi, DIB_RGB_COLORS, ppvBits, 0, 0 );
if (*phbmpDIB == NULL)
@ -108,18 +98,18 @@ BOOL InitStuff(void)
return FALSE;
}
if (!InitPerBitDepth(1, 9, 9, &ghdcBmp1, &ghbmp1, &ghdcDIB1, &ghbmpDIB1, &gpvDIB1) ||
!InitPerBitDepth(4, 5, 5, &ghdcBmp4, &ghbmp4, &ghdcDIB4, &ghbmpDIB4, &gpvDIB4) ||
!InitPerBitDepth(8, 5, 5, &ghdcBmp8, &ghbmp8, &ghdcDIB8, &ghbmpDIB8, &gpvDIB8) ||
!InitPerBitDepth(16, 5, 5, &ghdcBmp16, &ghbmp16, &ghdcDIB16, &ghbmpDIB16, &gpvDIB16) ||
!InitPerBitDepth(24, 5, 5, &ghdcBmp24, &ghbmp24, &ghdcDIB24, &ghbmpDIB24, &gpvDIB24) ||
!InitPerBitDepth(32, 4, 4, &ghdcBmp32, &ghbmp32, &ghdcDIB32, &ghbmpDIB32, &gpvDIB32))
if (!InitPerBitDepth(1, 9, 9, &ghbmp1, &ghdcDIB1, &ghbmpDIB1, &gpvDIB1) ||
!InitPerBitDepth(4, 5, 5, &ghbmp4, &ghdcDIB4, &ghbmpDIB4, &gpvDIB4) ||
!InitPerBitDepth(8, 5, 5, &ghbmp8, &ghdcDIB8, &ghbmpDIB8, &gpvDIB8) ||
!InitPerBitDepth(16, 8, 8, &ghbmp16, &ghdcDIB16, &ghbmpDIB16, &gpvDIB16) ||
!InitPerBitDepth(24, 8, 8, &ghbmp24, &ghdcDIB24, &ghbmpDIB24, &gpvDIB24) ||
!InitPerBitDepth(32, 8, 8, &ghbmp32, &ghdcDIB32, &ghbmpDIB32, &gpvDIB32))
{
printf("failed to create objects \n");
return FALSE;
}
pulDIB32Bits = gpvDIB32;
gpDIB32 = gpvDIB32;
pulDIB4Bits = gpvDIB4;
return TRUE;

View file

@ -1,12 +1,11 @@
extern HBITMAP ghbmp1, ghbmp4, ghbmp8, ghbmp16, ghbmp24, ghbmp32;
extern HDC ghdcBmp1, ghdcBmp4, ghdcBmp8, ghdcBmp16, ghdcBmp24, ghdcBmp32;
extern HBITMAP ghbmpDIB1, ghbmpDIB4, ghbmpDIB8, ghbmpDIB16, ghbmpDIB24, ghbmpDIB32;
extern HDC ghdcDIB1, ghdcDIB4, ghdcDIB8, ghdcDIB16, ghdcDIB24, ghdcDIB32;
extern PVOID pvBits1Bpp, pvBits4Bpp, pvBits8Bpp, pvBits16Bpp, pvBits24Bpp, pvBits32Bpp;
extern HBITMAP ghbmpDIB32;
extern PULONG pulDIB32Bits;
//extern PULONG pulDIB32Bits;
extern PULONG pulDIB4Bits;
extern HPALETTE ghpal;
typedef struct
@ -16,6 +15,8 @@ typedef struct
PALETTEENTRY logpalettedata[8];
} MYPAL;
extern ULONG (*gpDIB32)[8][8];
extern MYPAL gpal;
BOOL InitStuff(void);