ReactOS 0.4.15-dev-7906-g1b85a5f
CreateDIBitmap.c File Reference
#include "precomp.h"
#include "init.h"
#include <pseh/pseh2.h>
Include dependency graph for CreateDIBitmap.c:

Go to the source code of this file.

Macros

#define CBM_CREATDIB   2
 
#define INVALID_POINTER   ((PVOID)(ULONG_PTR)0xC0000000C0000000ULL)
 

Functions

BOOL GetExpected (DWORD *pdwError, HDC hdc, const BITMAPINFOHEADER *lpbmih, DWORD fdwInit, const VOID *lpbInit, const BITMAPINFO *lpbmi, UINT fuUsage)
 
void Test_CreateDIBitmap_Params (void)
 
void Test_CreateDIBitmap_DIB_PAL_COLORS (void)
 
void Test_CreateDIBitmap1 (void)
 
void Test_CreateDIBitmap_RLE8 ()
 
void Test_CreateDIBitmap_CBM_CREATDIB (void)
 
 START_TEST (CreateDIBitmap)
 

Macro Definition Documentation

◆ CBM_CREATDIB

#define CBM_CREATDIB   2

Definition at line 14 of file CreateDIBitmap.c.

◆ INVALID_POINTER

#define INVALID_POINTER   ((PVOID)(ULONG_PTR)0xC0000000C0000000ULL)

Definition at line 16 of file CreateDIBitmap.c.

Function Documentation

◆ GetExpected()

BOOL GetExpected ( DWORD pdwError,
HDC  hdc,
const BITMAPINFOHEADER lpbmih,
DWORD  fdwInit,
const VOID lpbInit,
const BITMAPINFO lpbmi,
UINT  fuUsage 
)

Definition at line 19 of file CreateDIBitmap.c.

27{
28 if (fuUsage > 2)
29 {
30 *pdwError = ERROR_INVALID_PARAMETER;
31 return FALSE;
32 }
33
34 if (fuUsage != DIB_RGB_COLORS)
35 {
36 if (hdc == (HDC)-1)
37 {
38 return FALSE;
39 }
40 }
41
42 if (fdwInit & CBM_INIT)
43 {
44 if (!lpbmih)
45 {
46 if (!lpbInit || (lpbInit == INVALID_POINTER)) return FALSE;
47 }
48 else
49 {
50 if (lpbInit)
51 {
52 if (lpbInit == INVALID_POINTER) return FALSE;
53 if (!lpbmi || (lpbmi == INVALID_POINTER)) return FALSE;
54 if (lpbmi->bmiHeader.biSize == 0) return FALSE;
55 if (fuUsage == 2) return FALSE;
56 }
57 }
58 }
59
60
61 if (fdwInit & CBM_CREATDIB)
62 {
63 if (fuUsage == 2) return FALSE;
64 if ((fuUsage == DIB_PAL_COLORS) && !hdc)
65 {
66 return FALSE;
67 }
68
69 if (fdwInit & CBM_INIT)
70 {
71 if (!lpbInit || (lpbInit == INVALID_POINTER)) return FALSE;
72 }
73
74 if ((!lpbmi) || (lpbmi == INVALID_POINTER) || (lpbmi->bmiHeader.biSize == 0))
75 {
76 return FALSE;
77 }
78 }
79 else
80 {
81
82 if ((lpbmih == NULL) ||
83 (lpbmih == INVALID_POINTER) ||
84 (lpbmih->biSize == 0))
85 {
86 return FALSE;
87 }
88
89 if (hdc == (HDC)-1)
90 {
91 *pdwError = ERROR_INVALID_PARAMETER;
92 return FALSE;
93 }
94
95
96 if (lpbmi == INVALID_POINTER) return FALSE;
97 }
98
99 return TRUE;
100}
#define INVALID_POINTER
#define CBM_CREATDIB
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
#define DIB_RGB_COLORS
Definition: wingdi.h:367
#define DIB_PAL_COLORS
Definition: wingdi.h:366
#define CBM_INIT
Definition: wingdi.h:365

Referenced by Test_CreateDIBitmap_Params().

◆ START_TEST()

START_TEST ( CreateDIBitmap  )

Definition at line 535 of file CreateDIBitmap.c.

536{
537 InitStuff();
543}
void Test_CreateDIBitmap_DIB_PAL_COLORS(void)
void Test_CreateDIBitmap_RLE8()
void Test_CreateDIBitmap_CBM_CREATDIB(void)
void Test_CreateDIBitmap_Params(void)
void Test_CreateDIBitmap1(void)
BOOL InitStuff(void)
Definition: init.c:95

◆ Test_CreateDIBitmap1()

void Test_CreateDIBitmap1 ( void  )

Definition at line 307 of file CreateDIBitmap.c.

308{
309 BITMAPINFO bmi;
312 ULONG bits[128] = {0};
313 BYTE rlebits[] = {2, 0, 0, 0, 2, 1, 0, 1};
314 HDC hdc;
315 int ret;
316
317 hdc = GetDC(0);
318
319 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
320 bmi.bmiHeader.biWidth = 3;
321 bmi.bmiHeader.biHeight = 2;
322 bmi.bmiHeader.biPlanes = 1;
323 bmi.bmiHeader.biBitCount = 16;
325 bmi.bmiHeader.biSizeImage = 0;
328 bmi.bmiHeader.biClrUsed = 0;
330
332 ok(hbmp != 0, "failed\n");
333
334 ret = GetObject(hbmp, sizeof(bitmap), &bitmap);
335 ok(ret != 0, "failed\n");
336 ok(bitmap.bmType == 0, "\n");
337 ok(bitmap.bmWidth == 3, "\n");
338 ok(bitmap.bmHeight == 2, "\n");
339 ok_int(bitmap.bmWidthBytes, ((bitmap.bmWidth * bitmap.bmBitsPixel + 15) & ~15) / 8);
340 ok(bitmap.bmPlanes == 1, "\n");
341 ok(bitmap.bmBitsPixel == GetDeviceCaps(hdc, BITSPIXEL), "\n");
342 ok(bitmap.bmBits == 0, "\n");
343
344 SetLastError(0);
346 bmi.bmiHeader.biBitCount = 8;
347 bmi.bmiHeader.biSizeImage = 8;
348 bmi.bmiHeader.biClrUsed = 1;
349 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, rlebits, &bmi, DIB_PAL_COLORS);
350 ok(hbmp != 0, "failed\n");
351 ok(GetLastError() == 0, "GetLastError() == %ld\n", GetLastError());
352
353 ret = GetObject(hbmp, sizeof(bitmap), &bitmap);
354 ok(ret != 0, "failed\n");
355 ok(bitmap.bmType == 0, "\n");
356 ok(bitmap.bmWidth == 3, "\n");
357 ok(bitmap.bmHeight == 2, "\n");
358 ok_int(bitmap.bmWidthBytes, ((bitmap.bmWidth * bitmap.bmBitsPixel + 15) & ~15) / 8);
359 ok(bitmap.bmPlanes == 1, "\n");
360 ok(bitmap.bmBitsPixel == GetDeviceCaps(hdc, BITSPIXEL), "\n");
361 ok(bitmap.bmBits == 0, "\n");
362
363
364}
#define ok(value,...)
Definition: atltest.h:57
#define ok_int(expression, result)
Definition: atltest.h:134
HBITMAP hbmp
#define SetLastError(x)
Definition: compat.h:752
#define BI_RGB
Definition: precomp.h:56
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
static HBITMAP
Definition: button.c:44
Definition: bl.h:1331
Definition: uimain.c:89
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
uint32_t ULONG
Definition: typedefs.h:59
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define BITSPIXEL
Definition: wingdi.h:720
#define BI_RLE8
Definition: wingdi.h:35
#define GetObject
Definition: wingdi.h:4468
HBITMAP WINAPI CreateDIBitmap(_In_ HDC hdc, _In_opt_ const BITMAPINFOHEADER *pbmih, _In_ DWORD fdwInit, _In_opt_ const VOID *pvInit, _In_opt_ const BITMAPINFO *pbmi, _In_ UINT uUsage)
HDC WINAPI GetDC(_In_opt_ HWND)
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ Test_CreateDIBitmap_CBM_CREATDIB()

void Test_CreateDIBitmap_CBM_CREATDIB ( void  )

Definition at line 419 of file CreateDIBitmap.c.

420{
422 HDC hdc;
423 BITMAPINFO bmi =
424 {{sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 1, 0}, {{0,1,2,3}}};
425 BYTE ajBits[10] = {0,1,2,3,4,5,6,7,8,9};
427 struct
428 {
429 BITMAPINFOHEADER bmiHeader;
430 WORD wColors[4];
431 } bmiRLE =
432 {
433 {sizeof(BITMAPINFOHEADER), 8, 2, 1, 8, BI_RLE8, 20, 1, 1, 4, 0},
434 {0, 1, 2, 7}
435 };
436 BYTE ajBitsRLE[] = {4,0, 0,2,0,1,0,2,3,1, 2,1, 2,2, 1,3,1,0,1,2, };
437
439 if (hdc == NULL)
440 {
441 ok(0, "CreateCompatibleDC failed. Skipping tests!\n");
442 return;
443 }
444
445 SetLastError(0xbadbad00);
447 ok(hbmp == 0, "CreateDIBitmap should fail.\n");
448 ok_int(GetLastError(), 0xbadbad00);
449
451 ok(hbmp != 0, "CreateDIBitmap failed.\n");
452
453 ok_long(GetObject(hbmp, sizeof(DIBSECTION), &bitmap), sizeof(BITMAP));
454 ok_int(bitmap.bmType, 0);
455 ok_int(bitmap.bmWidth, 4);
456 ok_int(bitmap.bmHeight, 4);
457 ok_int(bitmap.bmWidthBytes, 4);
458 ok_int(bitmap.bmPlanes, 1);
459 ok_int(bitmap.bmBitsPixel, 8);
460 ok_ptr(bitmap.bmBits, 0);
461
463 ok(hbmpOld != NULL, "Couldn't select the bitmap.\n");
464
465 /* Copy it on a dib section */
466 memset(gpDIB32, 0x77, sizeof(*gpDIB32));
467 ok_long(BitBlt(ghdcDIB32, 0, 0, 4, 4, hdc, 0, 0, SRCCOPY), 1);
468 ok_long((*gpDIB32)[0][0], 0x20100);
469 ok_long((*gpDIB32)[0][1], 0x20100);
470 ok_long((*gpDIB32)[0][2], 0x20100);
471 ok_long((*gpDIB32)[0][3], 0x20100);
472
475
477 ok(hbmp != 0, "CreateDIBitmap failed.\n");
478
479 ok_long(GetObject(hbmp, sizeof(DIBSECTION), &bitmap), sizeof(BITMAP));
480 ok_int(bitmap.bmType, 0);
481 ok_int(bitmap.bmWidth, 4);
482 ok_int(bitmap.bmHeight, 4);
483 ok_int(bitmap.bmWidthBytes, 4);
484 ok_int(bitmap.bmPlanes, 1);
485 ok_int(bitmap.bmBitsPixel, 8);
486 ok_ptr(bitmap.bmBits, 0);
487
488 /* Even with CBM_INIT and lpbmih != 0, pbmi is used for the dimensions */
489 hbmp = CreateDIBitmap(hdc, &bmiRLE.bmiHeader, CBM_CREATDIB | CBM_INIT, ajBits, &bmi, DIB_PAL_COLORS);
490 ok(hbmp != 0, "CreateDIBitmap failed.\n");
491
492 ok_long(GetObject(hbmp, sizeof(DIBSECTION), &bitmap), sizeof(BITMAP));
493 ok_int(bitmap.bmType, 0);
494 ok_int(bitmap.bmWidth, 4);
495 ok_int(bitmap.bmHeight, 4);
496 ok_int(bitmap.bmWidthBytes, 4);
497 ok_int(bitmap.bmPlanes, 1);
498 ok_int(bitmap.bmBitsPixel, 8);
499 ok_ptr(bitmap.bmBits, 0);
500
502 ok(hbmpOld != NULL, "Couldn't select the bitmap.\n");
503
504 /* Copy it on a dib section */
505 memset(gpDIB32, 0x77, sizeof(*gpDIB32));
506 ok_long(BitBlt(ghdcDIB32, 0, 0, 4, 4, hdc, 0, 0, SRCCOPY), 1);
507#if 0 // FIXME: fails on WHS testbot
508 ok_long((*gpDIB32)[0][0], 0);
509 ok_long((*gpDIB32)[0][1], 0);
510 ok_long((*gpDIB32)[0][2], 0);
511 ok_long((*gpDIB32)[0][3], 0);
512#endif
513
516
517 hbmp = CreateDIBitmap(hdc, NULL, CBM_CREATDIB, ajBitsRLE, (PVOID)&bmiRLE, DIB_PAL_COLORS);
518 ok(hbmp == 0, "CreateDIBitmap should fail.\n");
520 ok(hbmp == 0, "CreateDIBitmap should fail.\n");
521
522 /* Check if a 0 pixel bitmap results in the DEFAULT_BITMAP being returned */
523 bmi.bmiHeader.biWidth = 0;
524 bmi.bmiHeader.biHeight = 4;
526 ok(hbmp == GetStockObject(21), "CreateDIBitmap didn't return the default bitmap.\n");
527 bmi.bmiHeader.biWidth = 23;
528 bmi.bmiHeader.biHeight = 0;
530 ok(hbmp == GetStockObject(21), "CreateDIBitmap didn't return the default bitmap.\n");
531
532 DeleteDC(hdc);
533}
#define ok_long(expression, result)
Definition: atltest.h:133
#define ok_ptr(expression, result)
Definition: atltest.h:108
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
unsigned short WORD
Definition: ntddk_ex.h:93
pKey DeleteObject()
HANDLE hbmpOld
Definition: magnifier.c:54
ULONG(* gpDIB32)[8][8]
Definition: init.c:10
HDC ghdcDIB32
Definition: init.c:8
#define memset(x, y, z)
Definition: compat.h:39
HGDIOBJ WINAPI GetStockObject(_In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define SRCCOPY
Definition: wingdi.h:333
BOOL WINAPI DeleteDC(_In_ HDC)

Referenced by START_TEST().

◆ Test_CreateDIBitmap_DIB_PAL_COLORS()

void Test_CreateDIBitmap_DIB_PAL_COLORS ( void  )

Definition at line 258 of file CreateDIBitmap.c.

259{
260 struct
261 {
262 BITMAPINFOHEADER bmiHeader;
263 WORD bmiColors[8];
264 } bmibuffer;
265 BITMAPINFO *pbmi = (PVOID)&bmibuffer;
267 ULONG bits[16] = {0};
268 HDC hdc;
269 HPALETTE hpalOld;
270 USHORT i;
271
273 ok(hdc != 0, "failed\n");
274
275 /* Select a palette */
276 hpalOld = SelectPalette(hdc, ghpal, FALSE);
277 ok(hpalOld != NULL, "error=%ld\n", GetLastError());
278
279 /* Initialize a BITMAPINFO */
282 pbmi->bmiHeader.biHeight = -2;
291
292 for( i = 0; i < 8; i++ )
293 {
294 bmibuffer.bmiColors[i] = i;
295 }
296
297 /* Create the bitmap */
299 ok(hbmp != 0, "failed\n");
300
302
303
304}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HPALETTE ghpal
Definition: init.c:11
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
unsigned short USHORT
Definition: pedump.c:61
void * PVOID
Definition: typedefs.h:50
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)

Referenced by START_TEST().

◆ Test_CreateDIBitmap_Params()

void Test_CreateDIBitmap_Params ( void  )

Definition at line 104 of file CreateDIBitmap.c.

105{
107 HDC hdc;
108 BITMAPINFO bmi =
109 {{sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 1, 0}, {{0,0,0,0}}};
110 BITMAPINFO bmiBroken =
111 {{0, -2, -4, 55, 42, 21, 0, 1, 1, 1, 0}, {{0,0,0,0}}};
112 BYTE ajBits[10];
113
115 ok(hdc != 0, "failed\n");
116
117 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, ajBits, &bmi, DIB_PAL_COLORS);
118 ok(hbmp != 0, "\n");
119
121 ok(hbmp != 0, "\n");
122
124 ok(hbmp != 0, "\n");
125
127 ok(hbmp != 0, "\n");
128
130 ok(hbmp != 0, "\n");
131
133 ok(hbmp != 0, "\n");
134
135 hbmp = CreateDIBitmap(NULL, NULL, 2, NULL, &bmi, 0);
136 ok(hbmp != 0, "\n");
137
138 SetLastError(0xbadbad00);
140 ok(hbmp == 0, "\n");
142
143 SetLastError(0xbadbad00);
145 ok(hbmp == 0, "\n");
147
148 SetLastError(0xbadbad00);
149 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, ajBits, &bmi, 2);
150 ok(hbmp == 0, "\n");
152
153 SetLastError(0xbadbad00);
155 ok(hbmp == 0, "\n");
156 ok_err(0xbadbad00);
157
158 SetLastError(0xbadbad00);
160 ok(hbmp == 0, "\n");
161 ok_err(0xbadbad00);
162
163 SetLastError(0xbadbad00);
165 {
167 }
169 {
170 hbmp = (HBITMAP)-1;
171 }
172 _SEH2_END;
173 ok(hbmp == (HBITMAP)-1, "\n");
174 ok_err(0xbadbad00);
175
176 SetLastError(0xbadbad00);
178 ok(hbmp == 0, "\n");
180
181 SetLastError(0xbadbad00);
183 ok(hbmp == 0, "\n");
184 ok_err(0xbadbad00);
185
186 SetLastError(0xbadbad00);
188 ok(hbmp == 0, "\n");
190
191 if (1)
192 {
193 ULONG i1, i2, i3, i4, i5, i6;
194 HDC ahdc[3] = {0, hdc, (HDC)-1};
195 PBITMAPINFOHEADER apbih[4] = {NULL, &bmi.bmiHeader, &bmiBroken.bmiHeader, INVALID_POINTER};
196 ULONG afInitf[12] = {0, 1, CBM_CREATDIB, 3, CBM_INIT, 5, 6, 7, 8, 0x10, 0x20};
197 PVOID apvBits[3] = {NULL, ajBits, INVALID_POINTER};
198 PBITMAPINFO apbmi[4] = {NULL, &bmi, &bmiBroken, INVALID_POINTER};
199 ULONG aiUsage[5] = {0, 1, 2, 3, 23};
200 DWORD dwExpError;
201 BOOL bExpSuccess;
202
203 for (i1 = 0; i1 < ARRAYSIZE(ahdc); i1++)
204 {
205 for (i2 = 0; i2 < ARRAYSIZE(apbih); i2++)
206 {
207 for (i3 = 0; i3 < ARRAYSIZE(afInitf); i3++)
208 {
209 for (i4 = 0; i4 < ARRAYSIZE(apvBits); i4++)
210 {
211 for (i5 = 0; i5 < ARRAYSIZE(apbmi); i5++)
212 {
213 for (i6 = 0; i6 < ARRAYSIZE(aiUsage); i6++)
214 {
215 SetLastError(0xbadbad00);
216 dwExpError = 0xbadbad00;
217
218 bExpSuccess = GetExpected(&dwExpError, ahdc[i1], apbih[i2], afInitf[i3], apvBits[i4], apbmi[i5], aiUsage[i6]);
219
221 {
222 hbmp = CreateDIBitmap(ahdc[i1], apbih[i2], afInitf[i3], apvBits[i4], apbmi[i5], aiUsage[i6]);
223 }
225 {
226 hbmp = (HBITMAP)0;
227 }
228 _SEH2_END;
229
230 if (bExpSuccess)
231 {
232 ok(hbmp != 0, "Expected success for (%ld,%ld,%ld,%ld,%ld,%ld) CreateDIBitmap(%p, %p, 0x%lx, %p, %p, %ld)\n",
233 i1, i2, i3, i4, i5, i6,
234 ahdc[i1], apbih[i2], afInitf[i3], apvBits[i4], apbmi[i5], aiUsage[i6]);
235 }
236 else
237 {
238 ok(hbmp == 0, "Expected failure for (%ld,%ld,%ld,%ld,%ld,%ld) CreateDIBitmap(%p, %p, 0x%lx, %p, %p, %ld)\n",
239 i1, i2, i3, i4, i5, i6,
240 ahdc[i1], apbih[i2], afInitf[i3], apvBits[i4], apbmi[i5], aiUsage[i6]);
241 }
242
243 // ok(GetLastError() == dwExpError, "Expected error %ld got %ld for (%ld,%ld,%ld,%ld,%ld,%ld) CreateDIBitmap(%p, %p, 0x%lx, %p, %p, %ld)\n",
244 // dwExpError, GetLastError(), i1, i2, i3, i4, i5, i6,
245 // ahdc[i1], apbih[i2], afInitf[i3], apvBits[i4], apbmi[i5], aiUsage[i6]);
246 }
247 }
248 }
249 }
250 }
251 }
252 }
253
254
255}
BOOL GetExpected(DWORD *pdwError, HDC hdc, const BITMAPINFOHEADER *lpbmih, DWORD fdwInit, const VOID *lpbInit, const BITMAPINFO *lpbmi, UINT fuUsage)
#define ok_err(error)
Definition: atltest.h:124
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34

Referenced by START_TEST().

◆ Test_CreateDIBitmap_RLE8()

void Test_CreateDIBitmap_RLE8 ( )

Definition at line 366 of file CreateDIBitmap.c.

367{
368 struct
369 {
370 BITMAPINFOHEADER bmiHeader;
371 WORD wColors[4];
372 BYTE ajBuffer[20];
373 } PackedDIB =
374 {
375 {sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RLE8, 20, 1, 1, 4, 0},
376 {0, 1, 2, 7},
377 {4,0, 0,2,0,1,0,2,3,1, 2,1, 2,2, 1,3,1,0,1,2, },
378 };
379 HDC hdc;
381
383
384 SetLastError(0xbadbad00);
385 hbmp = CreateDIBitmap(hdc, &PackedDIB.bmiHeader, CBM_INIT, &PackedDIB.ajBuffer, (PVOID)&PackedDIB, DIB_PAL_COLORS);
386 ok(hbmp != 0, "CreateDIBitmap failed.\n");
387 ok_err(0xbadbad00);
389
390 PackedDIB.bmiHeader.biSizeImage = 2;
391 hbmp = CreateDIBitmap(hdc, &PackedDIB.bmiHeader, CBM_INIT, &PackedDIB.ajBuffer, (PVOID)&PackedDIB, DIB_PAL_COLORS);
392 ok(hbmp != 0, "CreateDIBitmap failed.\n");
393 ok_err(0xbadbad00);
395
396 PackedDIB.bmiHeader.biSizeImage = 1;
397 hbmp = CreateDIBitmap(hdc, &PackedDIB.bmiHeader, CBM_INIT, &PackedDIB.ajBuffer, (PVOID)&PackedDIB, DIB_PAL_COLORS);
398 ok(hbmp != 0, "CreateDIBitmap failed.\n");
399 ok_err(0xbadbad00);
401
402 PackedDIB.bmiHeader.biSizeImage = 0;
403 hbmp = CreateDIBitmap(hdc, &PackedDIB.bmiHeader, CBM_INIT, &PackedDIB.ajBuffer, (PVOID)&PackedDIB, DIB_PAL_COLORS);
404 ok(hbmp == 0, "CreateDIBitmap succeeded, expected failure\n");
405 ok_err(0xbadbad00);
406
407 /* Test a line that is too long */
408 PackedDIB.bmiHeader.biSizeImage = 20;
409 PackedDIB.ajBuffer[0] = 17;
410 hbmp = CreateDIBitmap(hdc, &PackedDIB.bmiHeader, CBM_INIT, &PackedDIB.ajBuffer, (PVOID)&PackedDIB, DIB_PAL_COLORS);
411 ok(hbmp != 0, "CreateDIBitmap failed\n");
412 ok_err(0xbadbad00);
414
415
416}

Referenced by START_TEST().