1 /* 2 * PROJECT: ReactOS api tests 3 * LICENSE: GPL - See COPYING in the top level directory 4 * PURPOSE: Test for NtGdiSetDIBitsToDeviceInternal 5 * PROGRAMMERS: 6 */ 7 8 #include <win32nt.h> 9 10 void 11 ReadBits(HDC hDC, PDWORD OutBits) 12 { 13 int x,y; 14 15 for (y = 0; y < 8; y++) 16 { 17 DWORD Row = 0; 18 for (x = 0; x < 8; x++) 19 Row |= (0x80 & GetPixel(hDC, 2 + x, 3 + y)) >> x; 20 OutBits[y] = Row; 21 } 22 } 23 24 25 START_TEST(NtGdiSetDIBitsToDeviceInternal) 26 { 27 static const DWORD InBits[8] = { 0x81, 0x7E, 0x5A, 0x7E, 0x7E, 0x42, 0x7E, 0x81 }; 28 DWORD OutBits[8]; 29 XFORM xform; 30 31 HWND hWnd = CreateWindowW(L"Static", NULL, WS_VISIBLE, 32 100, 100, 200, 200, 33 NULL, NULL, NULL, NULL); 34 /* This DC has an nonzero origin */ 35 HDC hDC = GetDC(hWnd); 36 struct 37 { 38 BITMAPINFOHEADER bmiHeader; 39 RGBQUAD bmiColors[2]; 40 } bmi; 41 int x, y; 42 43 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 44 bmi.bmiHeader.biWidth = 8; 45 bmi.bmiHeader.biHeight = -8; 46 bmi.bmiHeader.biPlanes = 1; 47 bmi.bmiHeader.biBitCount = 1; 48 bmi.bmiHeader.biCompression = 0; 49 bmi.bmiHeader.biSizeImage = 0; 50 bmi.bmiHeader.biXPelsPerMeter = 0; 51 bmi.bmiHeader.biYPelsPerMeter = 0; 52 bmi.bmiHeader.biClrUsed = 0; 53 bmi.bmiHeader.biClrImportant = 0; 54 *(DWORD *)&bmi.bmiColors[0] = 0x000000; 55 *(DWORD *)&bmi.bmiColors[1] = 0xFFFFFF; 56 57 /* The destination coordinates are relative to the DC origin */ 58 TEST(NtGdiSetDIBitsToDeviceInternal(hDC, 2, 3, 8, 8, 0, 0, 0, 8, 59 (PVOID)InBits, (BITMAPINFO *)&bmi, DIB_RGB_COLORS, 60 sizeof(InBits), sizeof(bmi), TRUE, NULL)); 61 62 /* Now get the data from the screen, and see if it matches */ 63 ReadBits(hDC, OutBits); 64 65 TEST(memcmp(InBits, OutBits, sizeof(InBits)) == 0); 66 67 /* Change transformation */ 68 GetWorldTransform(hDC, &xform); 69 xform.eM11 = 2; 70 xform.eM22 = 2; 71 xform.eDx = 10; 72 SetWorldTransform(hDC, &xform); 73 74 TEST(NtGdiSetDIBitsToDeviceInternal(hDC, 2, 3, 8, 8, 0, 0, 0, 8, 75 (PVOID)InBits, (BITMAPINFO *)&bmi, DIB_RGB_COLORS, 76 sizeof(InBits), sizeof(bmi), TRUE, NULL)); 77 78 xform.eM11 = 1; 79 xform.eM22 = 1; 80 xform.eDx = 0; 81 SetWorldTransform(hDC, &xform); 82 83 /* Now get the data from the screen, and see if it matches */ 84 for (y = 0; y < 8; y++) 85 { 86 DWORD Row = 0; 87 for (x = 0; x < 8; x++) 88 Row |= (0x80 & GetPixel(hDC, 2 + x, 3 + y)) >> x; 89 OutBits[y] = Row; 90 } 91 92 TEST(memcmp(InBits, OutBits, sizeof(InBits)) == 0); 93 94 95 ReleaseDC(hWnd, hDC); 96 DestroyWindow(hWnd); 97 98 } 99