42dc06049886d8b44facb8c8024bcbe1874a1411
[reactos.git] / rostests / apitests / gdi32 / SetDIBits.c
1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: GPL - See COPYING in the top level directory
4 * PURPOSE: Test for SetDIBits
5 * PROGRAMMERS: Jérôme Gardou
6 */
7
8 #include <stdio.h>
9 #include <wine/test.h>
10 #include <windows.h>
11
12
13 void Test_SetDIBits()
14 {
15 char buffer[sizeof(BITMAPINFOHEADER)+2*sizeof(RGBQUAD)];
16 ULONG* dibBuffer;
17 BITMAPINFO* pBMI = (BITMAPINFO*)buffer;
18 DWORD bits1bpp[2] = {0, 1};
19 HBITMAP hbmp;
20 int ret;
21
22 ZeroMemory(buffer, sizeof(buffer));
23
24 pBMI->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
25 pBMI->bmiHeader.biWidth=2;
26 pBMI->bmiHeader.biHeight=1;
27 pBMI->bmiHeader.biPlanes=1;
28 pBMI->bmiHeader.biBitCount=32;
29 pBMI->bmiHeader.biCompression=BI_RGB;
30 pBMI->bmiHeader.biSizeImage=0;
31 pBMI->bmiHeader.biXPelsPerMeter=0;
32 pBMI->bmiHeader.biYPelsPerMeter=0;
33 pBMI->bmiHeader.biClrUsed=0;
34 pBMI->bmiHeader.biClrImportant=0;
35
36 hbmp = CreateDIBSection(NULL, pBMI, DIB_RGB_COLORS, (PVOID*)&dibBuffer, NULL, 0);
37 ok(hbmp!=NULL, "Failed to create a DIB section\n");
38
39 pBMI->bmiHeader.biBitCount = 1;
40 pBMI->bmiColors[0].rgbBlue = 0xFF;
41 pBMI->bmiColors[0].rgbGreen = 0xFF;
42 pBMI->bmiColors[0].rgbRed = 0xFF;
43
44 ret = SetDIBits(NULL, hbmp, 0, 1, bits1bpp, pBMI, DIB_RGB_COLORS);
45 ok(ret == 1, "Copied %i scanlines\n", ret);
46
47 ok(dibBuffer[0] = 0xFFFFFF, "Wrong color 0x%08x after SetDIBits\n", (unsigned int)dibBuffer[0]);
48 ok(dibBuffer[1] = 0xFFFFFF, "Wrong color 0x%08x after SetDIBits\n", (unsigned int)dibBuffer[1]);
49
50 DeleteObject(hbmp);
51 }
52
53 START_TEST(SetDIBits)
54 {
55 Test_SetDIBits();
56 }