ReactOS 0.4.15-dev-7918-g2a2556c
SetDIBits.c File Reference
#include "precomp.h"
Include dependency graph for SetDIBits.c:

Go to the source code of this file.

Functions

void Test_SetDIBits ()
 
void Test_SetDIBits_1bpp ()
 
 START_TEST (SetDIBits)
 

Function Documentation

◆ START_TEST()

START_TEST ( SetDIBits  )

Definition at line 136 of file SetDIBits.c.

137{
140}
void Test_SetDIBits()
Definition: SetDIBits.c:10
void Test_SetDIBits_1bpp()
Definition: SetDIBits.c:50

◆ Test_SetDIBits()

void Test_SetDIBits ( )

Definition at line 10 of file SetDIBits.c.

11{
12 char buffer[sizeof(BITMAPINFOHEADER)+2*sizeof(RGBQUAD)];
13 ULONG* dibBuffer;
15 char bits1bpp[] = {0x80, 0, 0, 0};
17 int ret;
18
19 ZeroMemory(buffer, sizeof(buffer));
20
21 pBMI->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
22 pBMI->bmiHeader.biWidth=2;
23 pBMI->bmiHeader.biHeight=1;
24 pBMI->bmiHeader.biPlanes=1;
25 pBMI->bmiHeader.biBitCount=32;
27 pBMI->bmiHeader.biSizeImage=0;
30 pBMI->bmiHeader.biClrUsed=0;
32
33 hbmp = CreateDIBSection(NULL, pBMI, DIB_RGB_COLORS, (PVOID*)&dibBuffer, NULL, 0);
34 ok(hbmp!=NULL, "Failed to create a DIB section\n");
35
36 pBMI->bmiHeader.biBitCount = 1;
37 pBMI->bmiColors[0].rgbBlue = 0xFF;
38 pBMI->bmiColors[0].rgbGreen = 0;
39 pBMI->bmiColors[0].rgbRed = 0xFF;
40
41 ret = SetDIBits(NULL, hbmp, 0, 1, bits1bpp, pBMI, DIB_RGB_COLORS);
42 ok(ret == 1, "Copied %i scanlines\n", ret);
43
44 ok(dibBuffer[0] == 0, "Wrong color 0x%08x after SetDIBits\n", (unsigned int)dibBuffer[0]);
45 ok(dibBuffer[1] == 0xFF00FF, "Wrong color 0x%08x after SetDIBits\n", (unsigned int)dibBuffer[1]);
46
48}
#define ok(value,...)
Definition: atltest.h:57
HBITMAP hbmp
#define NULL
Definition: types.h:112
#define BI_RGB
Definition: precomp.h:56
ULONG RGBQUAD
Definition: precomp.h:59
pKey DeleteObject()
GLuint buffer
Definition: glext.h:5915
static HBITMAP
Definition: button.c:44
ULONG biClrImportant
Definition: precomp.h:52
USHORT biBitCount
Definition: precomp.h:46
LONG biYPelsPerMeter
Definition: precomp.h:50
ULONG biCompression
Definition: precomp.h:47
LONG biXPelsPerMeter
Definition: precomp.h:49
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
RGBQUAD bmiColors[1]
Definition: wingdi.h:1477
UCHAR rgbBlue
Definition: bootanim.c:103
UCHAR rgbRed
Definition: bootanim.c:105
UCHAR rgbGreen
Definition: bootanim.c:104
uint32_t ULONG
Definition: typedefs.h:59
int ret
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:245
#define ZeroMemory
Definition: winbase.h:1712
#define DIB_RGB_COLORS
Definition: wingdi.h:367
int WINAPI SetDIBits(_In_opt_ HDC, _In_ HBITMAP, _In_ UINT, _In_ UINT, _In_ CONST VOID *, _In_ CONST BITMAPINFO *, _In_ UINT)

Referenced by START_TEST().

◆ Test_SetDIBits_1bpp()

void Test_SetDIBits_1bpp ( )

Definition at line 50 of file SetDIBits.c.

51{
52 char buffer[sizeof(BITMAPINFOHEADER)+2*sizeof(RGBQUAD)];
53 HDC hdc;
55 char bits1bpp[] = {0x80, 0, 0, 0};
57 int ret;
59
61 if(!hdc)
62 {
63 trace("No device contexr !?\n");
64 return;
65 }
66
67 ZeroMemory(buffer, sizeof(buffer));
68
69 pBMI->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
70 pBMI->bmiHeader.biWidth=2;
71 pBMI->bmiHeader.biHeight=1;
72 pBMI->bmiHeader.biPlanes=1;
73 pBMI->bmiHeader.biBitCount=1;
75 pBMI->bmiHeader.biSizeImage=0;
78 pBMI->bmiHeader.biClrUsed=2;
80 pBMI->bmiColors[0].rgbBlue = 0xFF;
81 pBMI->bmiColors[0].rgbGreen = 0xFF;
82 pBMI->bmiColors[0].rgbRed = 0xFF;
83
84 hbmp = CreateBitmap(2, 1, 1, 1, NULL);
85 ok(hbmp!=NULL, "Failed to create a monochrome bitmap\n");
86
87 ret = SetDIBits(NULL, hbmp, 0, 1, bits1bpp, pBMI, DIB_RGB_COLORS);
88 ok(ret == 1, "Copied %i scanlines\n", ret);
89
91 ok(hbmp != NULL, "Could not select the bitmap into the context.\n");
92 color = GetPixel(hdc, 0,0);
93 ok(color == 0, "Wrong color at 0,0 : 0x%08x\n", (UINT)color);
94 color = GetPixel(hdc, 1,0);
95 ok(color == 0xFFFFFF, "Wrong color at 1,0 : 0x%08x\n", (UINT)color);
96
98
99 /* Try something else than 0xFFFFFF */
100 pBMI->bmiColors[0].rgbBlue = 0xFF;
101 pBMI->bmiColors[0].rgbGreen = 0;
102 pBMI->bmiColors[0].rgbRed = 0;
103
104 ret = SetDIBits(NULL, hbmp, 0, 1, bits1bpp, pBMI, DIB_RGB_COLORS);
105 ok(ret == 1, "Copied %i scanlines\n", ret);
106
108 ok(hbmp != NULL, "Could not select the bitmap into the context.\n");
109 color = GetPixel(hdc, 0,0);
110 ok(color == 0, "Wrong color at 0,0 : 0x%08x\n", (UINT)color);
111 color = GetPixel(hdc, 1,0);
112 ok(color == 0xFFFFFF, "Wrong color at 1,0 : 0x%08x\n", (UINT)color);
113
115
116 /* Special : try 0 */
117 pBMI->bmiColors[0].rgbBlue = 0;
118 pBMI->bmiColors[0].rgbGreen = 0;
119 pBMI->bmiColors[0].rgbRed = 0;
120
121 ret = SetDIBits(NULL, hbmp, 0, 1, bits1bpp, pBMI, DIB_RGB_COLORS);
122 ok(ret == 1, "Copied %i scanlines\n", ret);
123
125 ok(hbmp != NULL, "Could not select the bitmap into the context.\n");
126 color = GetPixel(hdc, 0,0);
127 ok(color == 0, "Wrong color at 0,0 : 0x%08x\n", (UINT)color);
128 color = GetPixel(hdc, 1,0);
129 ok(color == 0xFFFFFF, "Wrong color at 1,0 : 0x%08x\n", (UINT)color);
130
133 DeleteDC(hdc);
134}
#define trace
Definition: atltest.h:70
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
GLuint color
Definition: glext.h:6243
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
unsigned int UINT
Definition: ndis.h:50
DWORD COLORREF
Definition: windef.h:300
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by START_TEST().