Added dibtest - only 1BPP test for now
[reactos.git] / reactos / apps / tests / dibtest / dibtest.c
1 #include <windows.h>
2
3 extern BOOL STDCALL GdiDllInitialize(HANDLE hInstance, DWORD Event, LPVOID Reserved);
4
5 void __stdcall Test1BPP (HDC Desktop)
6 {
7 HDC TestDC;
8 HPEN WhitePen;
9 HBITMAP DIB1;
10 BITMAPINFOHEADER BitInf;
11 PBITMAPINFO BitPalInf;
12 DWORD bmiSize = sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 2;
13
14 // Create a 1BPP DIB
15 BitPalInf = (PBITMAPINFO)malloc(bmiSize);
16 BitInf.biSize = sizeof(BITMAPINFOHEADER);
17 BitInf.biWidth = 50;
18 BitInf.biHeight = -50; // it's top down (since BI_RGB is used, the sign is operative of direction)
19 BitInf.biPlanes = 1;
20 BitInf.biBitCount = 1;
21 BitInf.biCompression = BI_RGB;
22 BitInf.biSizeImage = 0;
23 BitInf.biXPelsPerMeter = 0;
24 BitInf.biYPelsPerMeter = 0;
25 BitInf.biClrUsed = 0;
26 BitInf.biClrImportant = 0;
27 BitPalInf->bmiHeader = BitInf;
28 BitPalInf->bmiColors[1].rgbBlue = 255;
29 BitPalInf->bmiColors[1].rgbGreen = 255;
30 BitPalInf->bmiColors[1].rgbRed = 255;
31 BitPalInf->bmiColors[1].rgbReserved = 255;
32 BitPalInf->bmiColors[0].rgbBlue = 0;
33 BitPalInf->bmiColors[0].rgbGreen = 0;
34 BitPalInf->bmiColors[0].rgbRed = 0;
35 BitPalInf->bmiColors[0].rgbReserved = 0;
36
37 DIB1 = (HBITMAP) CreateDIBSection(NULL, BitPalInf, DIB_RGB_COLORS, NULL, NULL, 0);
38 TestDC = CreateCompatibleDC(NULL);
39 SelectObject(TestDC, DIB1);
40
41 // Draw a white rectangle on the 1BPP DIB
42 WhitePen = CreatePen(PS_SOLID, 1, RGB(255, 255, 255));
43 SelectObject(TestDC, WhitePen);
44 Rectangle(TestDC, 0, 0, 40, 40);
45
46 // Blt the 1BPP DIB to the display
47 BitBlt(Desktop, 0, 0, 50, 50, TestDC, 0, 0, SRCCOPY);
48
49 free(BitPalInf);
50 // Rectangle(Desktop, 50, 50, 200, 200);
51 }
52
53 void DIBTest(void)
54 {
55 HDC Desktop;
56
57 // Set up a DC called Desktop that accesses DISPLAY
58 Desktop = CreateDCA("DISPLAY", NULL, NULL, NULL);
59 if(Desktop == NULL) {
60 printf("Can't create desktop\n");
61 return;
62 }
63
64 // 1BPP Test
65 Test1BPP(Desktop);
66
67 Sleep(10000);
68
69 // Free up everything
70 DeleteDC(Desktop);
71 }
72
73 int main(int argc, char* argv[])
74 {
75 printf("Entering DIBTest..\n");
76
77 GdiDllInitialize (NULL, DLL_PROCESS_ATTACH, NULL);
78 DIBTest();
79
80 return 0;
81 }