reactos/rostests/apitests/gdi32api/tests/GetDIBits.c
Ged Murphy f26bd07f86 Add basic tests for GetDIBits
svn path=/trunk/; revision=29190
2007-09-24 15:02:20 +00:00

50 lines
1.4 KiB
C

INT
Test_GetDIBits(PTESTINFO pti)
{
HDC hDCScreen;
HBITMAP hBitmap;
BITMAPINFO bi;
INT ScreenBpp;
hDCScreen = GetDC(NULL);
if (hDCScreen == NULL)
{
return FALSE;
}
hBitmap = CreateCompatibleBitmap(hDCScreen, 16, 16);
RTEST(hBitmap != NULL);
SetLastError(ERROR_SUCCESS);
RTEST(GetDIBits(0, 0, 0, 0, NULL, NULL, 0) == 0);
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
SetLastError(ERROR_SUCCESS);
RTEST(GetDIBits((HDC)2345, 0, 0, 0, NULL, NULL, 0) == 0);
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
SetLastError(ERROR_SUCCESS);
RTEST(GetDIBits((HDC)2345, hBitmap, 0, 0, NULL, NULL, 0) == 0);
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
SetLastError(ERROR_SUCCESS);
RTEST(GetDIBits((HDC)2345, hBitmap, 0, 15, NULL, &bi, 0) == 0);
RTEST(GetLastError() == ERROR_INVALID_PARAMETER);
SetLastError(ERROR_SUCCESS);
ZeroMemory(&bi, sizeof(BITMAPINFO));
bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
RTEST(GetDIBits(hDCScreen, hBitmap, 0, 15, NULL, &bi, DIB_RGB_COLORS) > 0);
RTEST(GetLastError() == ERROR_SUCCESS);
ScreenBpp = GetDeviceCaps(hDCScreen, BITSPIXEL);
RTEST(bi.bmiHeader.biWidth == 16);
RTEST(bi.bmiHeader.biHeight == 16);
RTEST(bi.bmiHeader.biBitCount == ScreenBpp);
RTEST(bi.bmiHeader.biSizeImage == (16 * 16) * (ScreenBpp / 8));
DeleteObject(hBitmap);
ReleaseDC(NULL, hDCScreen);
return APISTATUS_NORMAL;
}