From: Ged Murphy Date: Mon, 24 Sep 2007 15:09:15 +0000 (+0000) Subject: Add basic tests for NtGdiGetDIBitsInternal X-Git-Tag: backups/win32k-stable@33466~226 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=9be6565d51bd3e2a0b3fe2678e52c295d27876cc Add basic tests for NtGdiGetDIBitsInternal svn path=/trunk/; revision=29191 --- diff --git a/rostests/apitests/w32knapi/ntgdi/NtGdiGetDIBits.c b/rostests/apitests/w32knapi/ntgdi/NtGdiGetDIBits.c new file mode 100644 index 00000000000..e1fc9488f5d --- /dev/null +++ b/rostests/apitests/w32knapi/ntgdi/NtGdiGetDIBits.c @@ -0,0 +1,71 @@ +/* taken from gdi32, bitmap.c */ +UINT +FASTCALL +DIB_BitmapMaxBitsSize( PBITMAPINFO Info, UINT ScanLines ) +{ + UINT MaxBits = 0; + + if (Info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) + { + PBITMAPCOREHEADER Core = (PBITMAPCOREHEADER)Info; + MaxBits = Core->bcBitCount * Core->bcPlanes * Core->bcWidth; + } + else /* assume BITMAPINFOHEADER */ + { + if ((Info->bmiHeader.biCompression) && (Info->bmiHeader.biCompression != BI_BITFIELDS)) + return Info->bmiHeader.biSizeImage; + // Planes are over looked by Yuan. I guess assumed always 1. + MaxBits = Info->bmiHeader.biBitCount * Info->bmiHeader.biPlanes * Info->bmiHeader.biWidth; + } + MaxBits = ((MaxBits + 31) & ~31 ) / 8; // From Yuan, ScanLineSize = (Width * bitcount + 31)/32 + return (MaxBits * ScanLines); // ret the full Size. +} + + +INT +Test_NtGdiGetDIBitsInternal(PTESTINFO pti) +{ + HBITMAP hBitmap; + BITMAPINFO bi; + INT ScreenBpp; + + HDC hDCScreen = GetDC(NULL); + ASSERT(hDCScreen != NULL); + + hBitmap = CreateCompatibleBitmap(hDCScreen, 16, 16); + ASSERT(hBitmap != NULL); + + SetLastError(ERROR_SUCCESS); + RTEST(NtGdiGetDIBitsInternal(0, 0, 0, 0, NULL, NULL, 0, 0, 0) == 0); + RTEST(GetLastError() == ERROR_SUCCESS); + + SetLastError(ERROR_SUCCESS); + RTEST(NtGdiGetDIBitsInternal((HDC)2345, 0, 0, 0, NULL, NULL, 0, 0, 0) == 0); + RTEST(GetLastError() == ERROR_SUCCESS); + + SetLastError(ERROR_SUCCESS); + RTEST(NtGdiGetDIBitsInternal((HDC)2345, hBitmap, 0, 0, NULL, NULL, 0, 0, 0) == 0); + RTEST(GetLastError() == ERROR_SUCCESS); + + SetLastError(ERROR_SUCCESS); + RTEST(NtGdiGetDIBitsInternal((HDC)2345, hBitmap, 0, 15, NULL, &bi, 0, 0, 0) == 0); + RTEST(GetLastError() == ERROR_SUCCESS); + + SetLastError(ERROR_SUCCESS); + ZeroMemory(&bi, sizeof(BITMAPINFO)); + bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + RTEST(NtGdiGetDIBitsInternal(hDCScreen, hBitmap, 0, 15, NULL, &bi, DIB_RGB_COLORS, + DIB_BitmapMaxBitsSize(&bi, 15), 0) > 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)); + + ReleaseDC(NULL, hDCScreen); + DeleteObject(hBitmap); + + return APISTATUS_NORMAL; +} diff --git a/rostests/apitests/w32knapi/testlist.c b/rostests/apitests/w32knapi/testlist.c index b156766c224..b0ab9b7a81e 100644 --- a/rostests/apitests/w32knapi/testlist.c +++ b/rostests/apitests/w32knapi/testlist.c @@ -17,6 +17,7 @@ #include "ntgdi/NtGdiGetRandomRgn.c" #include "ntgdi/NtGdiSetBitmapBits.c" //#include "ntgdi/NtGdiSTROBJ_vEnumStart.c" +#include "ntgdi/NtGdiGetDIBits.c" #include "ntuser/NtUserCountClipboardFormats.c" @@ -40,6 +41,7 @@ TESTENTRY TestList[] = { L"NtGdiGetRandomRgn", Test_NtGdiGetRandomRgn }, { L"NtGdiSetBitmapBits", Test_NtGdiSetBitmapBits }, // { L"NtGdiSTROBJ_vEnumStart", Test_NtGdiSTROBJ_vEnumStart }, + { L"NtGdiGetDIBitsInternal", Test_NtGdiGetDIBitsInternal }, /* ntuser */ { L"NtUserCountClipboardFormats", Test_NtUserCountClipboardFormats }