1 /*
2  * PROJECT:         ReactOS api tests
3  * LICENSE:         GPL - See COPYING in the top level directory
4  * PURPOSE:         Test for CreateDIBitmap
5  * PROGRAMMERS:     Timo Kreuzer
6  */
7 
8 #include "precomp.h"
9 
10 #include "init.h"
11 
12 #define CBM_CREATDIB 2
13 
14 #define INVALID_POINTER ((PVOID)(ULONG_PTR)0xC0000000C0000000ULL)
15 
16 BOOL
17 GetExpected(
18     DWORD *pdwError,
19     HDC hdc,
20     const BITMAPINFOHEADER *lpbmih,
21     DWORD fdwInit,
22     const VOID *lpbInit,
23     const BITMAPINFO *lpbmi,
24     UINT fuUsage)
25 {
26     if (fuUsage > 2)
27     {
28         *pdwError = ERROR_INVALID_PARAMETER;
29         return FALSE;
30     }
31 
32     if (fuUsage != DIB_RGB_COLORS)
33     {
34         if (hdc == (HDC)-1)
35         {
36             return FALSE;
37         }
38     }
39 
40     if (fdwInit & CBM_INIT)
41     {
42         if (!lpbmih)
43         {
44             if (!lpbInit || (lpbInit == INVALID_POINTER)) return FALSE;
45         }
46         else
47         {
48             if (lpbInit)
49             {
50                 if (lpbInit == INVALID_POINTER) return FALSE;
51                 if (!lpbmi || (lpbmi == INVALID_POINTER)) return FALSE;
52                 if (lpbmi->bmiHeader.biSize == 0) return FALSE;
53                 if (fuUsage == 2) return FALSE;
54             }
55         }
56     }
57 
58 
59     if (fdwInit & CBM_CREATDIB)
60     {
61         if (fuUsage == 2) return FALSE;
62         if ((fuUsage == DIB_PAL_COLORS) && !hdc)
63         {
64             return FALSE;
65         }
66 
67         if (fdwInit & CBM_INIT)
68         {
69             if (!lpbInit || (lpbInit == INVALID_POINTER)) return FALSE;
70         }
71 
72         if ((!lpbmi) || (lpbmi == INVALID_POINTER) || (lpbmi->bmiHeader.biSize == 0))
73         {
74             return FALSE;
75         }
76     }
77     else
78     {
79 
80         if ((lpbmih == NULL) ||
81             (lpbmih == INVALID_POINTER) ||
82             (lpbmih->biSize == 0))
83         {
84             return FALSE;
85         }
86 
87         if (hdc == (HDC)-1)
88         {
89             *pdwError = ERROR_INVALID_PARAMETER;
90             return FALSE;
91         }
92 
93 
94         if (lpbmi == INVALID_POINTER) return FALSE;
95     }
96 
97     return TRUE;
98 }
99 
100 
101 void
102 Test_CreateDIBitmap_Params(void)
103 {
104     HBITMAP hbmp;
105     HDC hdc;
106     BITMAPINFO bmi =
107         {{sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 1, 0}, {{0,0,0,0}}};
108     BITMAPINFO bmiBroken =
109         {{0, -2, -4, 55, 42, 21, 0, 1, 1, 1, 0}, {{0,0,0,0}}};
110     BYTE ajBits[10];
111 
112     hdc = CreateCompatibleDC(0);
113     ok(hdc != 0, "failed\n");
114 
115     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, ajBits, &bmi, DIB_PAL_COLORS);
116     ok(hbmp != 0, "\n");
117 
118     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, NULL, &bmi, DIB_PAL_COLORS);
119     ok(hbmp != 0, "\n");
120 
121     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, NULL, NULL, DIB_PAL_COLORS);
122     ok(hbmp != 0, "\n");
123 
124     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, 0, INVALID_POINTER, &bmi, DIB_PAL_COLORS);
125     ok(hbmp != 0, "\n");
126 
127     hbmp = CreateDIBitmap(NULL, &bmi.bmiHeader, CBM_INIT, NULL, &bmi, DIB_PAL_COLORS);
128     ok(hbmp != 0, "\n");
129 
130     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, NULL, &bmiBroken, DIB_PAL_COLORS);
131     ok(hbmp != 0, "\n");
132 
133     hbmp = CreateDIBitmap(NULL, NULL, 2, NULL, &bmi, 0);
134     ok(hbmp != 0, "\n");
135 
136     SetLastError(0xbadbad00);
137     hbmp = CreateDIBitmap(hdc, NULL, CBM_INIT, ajBits, &bmi, DIB_PAL_COLORS);
138     ok(hbmp == 0, "\n");
139     ok_err(ERROR_INVALID_PARAMETER);
140 
141     SetLastError(0xbadbad00);
142     hbmp = CreateDIBitmap(hdc, NULL, CBM_INIT, NULL, &bmiBroken, DIB_PAL_COLORS);
143     ok(hbmp == 0, "\n");
144     ok_err(ERROR_INVALID_PARAMETER);
145 
146     SetLastError(0xbadbad00);
147     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, ajBits, &bmi, 2);
148     ok(hbmp == 0, "\n");
149     ok_err(ERROR_INVALID_PARAMETER);
150 
151     SetLastError(0xbadbad00);
152     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, ajBits, NULL, DIB_PAL_COLORS);
153     ok(hbmp == 0, "\n");
154     ok_err(0xbadbad00);
155 
156     SetLastError(0xbadbad00);
157     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, INVALID_POINTER, &bmi, DIB_PAL_COLORS);
158     ok(hbmp == 0, "\n");
159     ok_err(0xbadbad00);
160 
161     SetLastError(0xbadbad00);
162     _SEH2_TRY
163     {
164         hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, 0, ajBits, INVALID_POINTER, DIB_PAL_COLORS);
165     }
166     _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
167     {
168         hbmp = (HBITMAP)-1;
169     }
170     _SEH2_END;
171     ok(hbmp == (HBITMAP)-1, "\n");
172     ok_err(0xbadbad00);
173 
174     SetLastError(0xbadbad00);
175     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, NULL, NULL, 5);
176     ok(hbmp == 0, "\n");
177     ok_err(ERROR_INVALID_PARAMETER);
178 
179     SetLastError(0xbadbad00);
180     hbmp = CreateDIBitmap((HDC)-1, &bmi.bmiHeader, CBM_INIT, NULL, &bmi, DIB_PAL_COLORS);
181     ok(hbmp == 0, "\n");
182     ok_err(0xbadbad00);
183 
184     SetLastError(0xbadbad00);
185     hbmp = CreateDIBitmap(hdc, &bmiBroken.bmiHeader, CBM_INIT, NULL, &bmi, DIB_PAL_COLORS);
186     ok(hbmp == 0, "\n");
187     ok_err(ERROR_INVALID_PARAMETER);
188 
189     if (1)
190     {
191         ULONG i1, i2, i3, i4, i5, i6;
192         HDC ahdc[3] = {0, hdc, (HDC)-1};
193         PBITMAPINFOHEADER apbih[4] = {NULL, &bmi.bmiHeader, &bmiBroken.bmiHeader, INVALID_POINTER};
194         ULONG afInitf[12] = {0, 1, 2, 3, CBM_INIT, 4, 5, 6, 7, 8, 0x10, 0x20};
195         PVOID apvBits[3] = {NULL, ajBits, INVALID_POINTER};
196         PBITMAPINFO apbmi[4] = {NULL, &bmi, &bmiBroken, INVALID_POINTER};
197         ULONG aiUsage[5] = {0, 1, 2, 3, 23};
198         DWORD dwExpError;
199         BOOL bExpSuccess;
200 
201         for (i1 = 0; i1 < 3; i1++)
202         {
203             for (i2 = 0; i2 < 4; i2++)
204             {
205                 for (i3 = 0; i3 < 8; i3++)
206                 {
207                     for (i4 = 0; i4 < 3; i4++)
208                     {
209                         for (i5 = 0; i5 < 4; i5++)
210                         {
211                             for (i6 = 0; i6 < 5; i6++)
212                             {
213                                 SetLastError(0xbadbad00);
214                                 dwExpError = 0xbadbad00;
215 
216                                 bExpSuccess = GetExpected(&dwExpError, ahdc[i1], apbih[i2], afInitf[i3], apvBits[i4], apbmi[i5], aiUsage[i6]);
217 
218                                 _SEH2_TRY
219                                 {
220                                     hbmp = CreateDIBitmap(ahdc[i1], apbih[i2], afInitf[i3], apvBits[i4], apbmi[i5], aiUsage[i6]);
221                                 }
222                                 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
223                                 {
224                                     hbmp = (HBITMAP)0;
225                                 }
226                                 _SEH2_END;
227 
228                                 if (bExpSuccess)
229                                 {
230                                     ok(hbmp != 0, "Expected success for (%ld,%ld,%ld,%ld,%ld,%ld) CreateDIBitmap(%p, %p, 0x%lx, %p, %p, %ld)\n",
231                                        i1, i2, i3, i4, i5, i6,
232                                        ahdc[i1], apbih[i2], afInitf[i3], apvBits[i4], apbmi[i5], aiUsage[i6]);
233                                 }
234                                 else
235                                 {
236                                     ok(hbmp == 0, "Expected failure for (%ld,%ld,%ld,%ld,%ld,%ld) CreateDIBitmap(%p, %p, 0x%lx, %p, %p, %ld)\n",
237                                        i1, i2, i3, i4, i5, i6,
238                                        ahdc[i1], apbih[i2], afInitf[i3], apvBits[i4], apbmi[i5], aiUsage[i6]);
239                                 }
240 
241                               //  ok(GetLastError() == dwExpError, "Expected error %ld got %ld for (%ld,%ld,%ld,%ld,%ld,%ld) CreateDIBitmap(%p, %p, 0x%lx, %p, %p, %ld)\n",
242                               //         dwExpError, GetLastError(), i1, i2, i3, i4, i5, i6,
243                               //         ahdc[i1], apbih[i2], afInitf[i3], apvBits[i4], apbmi[i5], aiUsage[i6]);
244                             }
245                         }
246                     }
247                 }
248             }
249         }
250     }
251 
252 
253 }
254 
255 void
256 Test_CreateDIBitmap_DIB_PAL_COLORS(void)
257 {
258     struct
259     {
260         BITMAPINFOHEADER bmiHeader;
261         WORD bmiColors[8];
262     } bmibuffer;
263     BITMAPINFO *pbmi = (PVOID)&bmibuffer;
264     HBITMAP hbmp;
265     ULONG bits[16] = {0};
266     HDC hdc;
267     HPALETTE hpalOld;
268     USHORT i;
269 
270     hdc = CreateCompatibleDC(0);
271     ok(hdc != 0, "failed\n");
272 
273     /* Select a palette */
274     hpalOld = SelectPalette(hdc, ghpal, FALSE);
275     ok(hpalOld != NULL, "error=%ld\n", GetLastError());
276 
277     /* Initialize a BITMAPINFO */
278     pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
279     pbmi->bmiHeader.biWidth = 2;
280     pbmi->bmiHeader.biHeight = -2;
281     pbmi->bmiHeader.biPlanes = 1;
282     pbmi->bmiHeader.biBitCount = 8;
283     pbmi->bmiHeader.biCompression = BI_RGB;
284     pbmi->bmiHeader.biSizeImage = 0;
285     pbmi->bmiHeader.biXPelsPerMeter = 1;
286     pbmi->bmiHeader.biYPelsPerMeter = 1;
287     pbmi->bmiHeader.biClrUsed = 8;
288     pbmi->bmiHeader.biClrImportant = 0;
289 
290     for( i = 0; i < 8; i++ )
291     {
292         bmibuffer.bmiColors[i] = i;
293     }
294 
295     /* Create the bitmap */
296     hbmp = CreateDIBitmap(hdc, &pbmi->bmiHeader, CBM_INIT, bits, pbmi, DIB_PAL_COLORS);
297     ok(hbmp != 0, "failed\n");
298 
299     SelectObject(hdc, hbmp);
300 
301 
302 }
303 
304 void
305 Test_CreateDIBitmap1(void)
306 {
307     BITMAPINFO bmi;
308     HBITMAP hbmp;
309     BITMAP bitmap;
310     ULONG bits[128] = {0};
311     BYTE rlebits[] = {2, 0, 0, 0, 2, 1, 0, 1};
312     HDC hdc;
313     int ret;
314 
315     hdc = GetDC(0);
316 
317     bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
318     bmi.bmiHeader.biWidth = 2;
319     bmi.bmiHeader.biHeight = 2;
320     bmi.bmiHeader.biPlanes = 1;
321     bmi.bmiHeader.biBitCount = 16;
322     bmi.bmiHeader.biCompression = BI_RGB;
323     bmi.bmiHeader.biSizeImage = 0;
324     bmi.bmiHeader.biXPelsPerMeter = 1;
325     bmi.bmiHeader.biYPelsPerMeter = 1;
326     bmi.bmiHeader.biClrUsed = 0;
327     bmi.bmiHeader.biClrImportant = 0;
328 
329     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, bits, &bmi, DIB_RGB_COLORS);
330     ok(hbmp != 0, "failed\n");
331 
332     ret = GetObject(hbmp, sizeof(bitmap), &bitmap);
333     ok(ret != 0, "failed\n");
334     ok(bitmap.bmType == 0, "\n");
335     ok(bitmap.bmWidth == 2, "\n");
336     ok(bitmap.bmHeight == 2, "\n");
337     ok(bitmap.bmWidthBytes == 8, "bmWidthBytes = %ld\n", bitmap.bmWidthBytes);
338     ok(bitmap.bmPlanes == 1, "\n");
339     ok(bitmap.bmBitsPixel == GetDeviceCaps(hdc, BITSPIXEL), "\n");
340     ok(bitmap.bmBits == 0, "\n");
341 
342     SetLastError(0);
343     bmi.bmiHeader.biCompression = BI_RLE8;
344     bmi.bmiHeader.biBitCount = 8;
345     bmi.bmiHeader.biSizeImage = 8;
346     bmi.bmiHeader.biClrUsed = 1;
347     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, rlebits, &bmi, DIB_PAL_COLORS);
348     ok(hbmp != 0, "failed\n");
349     ok(GetLastError() == 0, "GetLastError() == %ld\n", GetLastError());
350 
351     ret = GetObject(hbmp, sizeof(bitmap), &bitmap);
352     ok(ret != 0, "failed\n");
353     ok(bitmap.bmType == 0, "\n");
354     ok(bitmap.bmWidth == 2, "\n");
355     ok(bitmap.bmHeight == 2, "\n");
356     ok(bitmap.bmWidthBytes == 8, "bmWidthBytes = %ld\n", bitmap.bmWidthBytes);
357     ok(bitmap.bmPlanes == 1, "\n");
358     ok(bitmap.bmBitsPixel == GetDeviceCaps(hdc, BITSPIXEL), "\n");
359     ok(bitmap.bmBits == 0, "\n");
360 
361 
362 }
363 
364 void Test_CreateDIBitmap_RLE8()
365 {
366     struct
367     {
368         BITMAPINFOHEADER bmiHeader;
369         WORD wColors[4];
370         BYTE ajBuffer[20];
371     } PackedDIB =
372     {
373         {sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RLE8, 20, 1, 1, 4, 0},
374         {0, 1, 2, 7},
375         {4,0,   0,2,0,1,0,2,3,1,   2,1, 2,2,   1,3,1,0,1,2, },
376     };
377     HDC hdc;
378     HBITMAP hbmp;
379 
380     hdc = CreateCompatibleDC(0);
381 
382     SetLastError(0xbadbad00);
383     hbmp = CreateDIBitmap(hdc, &PackedDIB.bmiHeader, CBM_INIT, &PackedDIB.ajBuffer, (PVOID)&PackedDIB, DIB_PAL_COLORS);
384     ok(hbmp != 0, "CreateDIBitmap failed.\n");
385     ok_err(0xbadbad00);
386     DeleteObject(hbmp);
387 
388     PackedDIB.bmiHeader.biSizeImage = 2;
389     hbmp = CreateDIBitmap(hdc, &PackedDIB.bmiHeader, CBM_INIT, &PackedDIB.ajBuffer, (PVOID)&PackedDIB, DIB_PAL_COLORS);
390     ok(hbmp != 0, "CreateDIBitmap failed.\n");
391     ok_err(0xbadbad00);
392     DeleteObject(hbmp);
393 
394     PackedDIB.bmiHeader.biSizeImage = 1;
395     hbmp = CreateDIBitmap(hdc, &PackedDIB.bmiHeader, CBM_INIT, &PackedDIB.ajBuffer, (PVOID)&PackedDIB, DIB_PAL_COLORS);
396     ok(hbmp != 0, "CreateDIBitmap failed.\n");
397     ok_err(0xbadbad00);
398     DeleteObject(hbmp);
399 
400     PackedDIB.bmiHeader.biSizeImage = 0;
401     hbmp = CreateDIBitmap(hdc, &PackedDIB.bmiHeader, CBM_INIT, &PackedDIB.ajBuffer, (PVOID)&PackedDIB, DIB_PAL_COLORS);
402     ok(hbmp == 0, "CreateDIBitmap succeeded, expected failure\n");
403     ok_err(0xbadbad00);
404 
405     /* Test a line that is too long */
406     PackedDIB.bmiHeader.biSizeImage = 20;
407     PackedDIB.ajBuffer[0] = 17;
408     hbmp = CreateDIBitmap(hdc, &PackedDIB.bmiHeader, CBM_INIT, &PackedDIB.ajBuffer, (PVOID)&PackedDIB, DIB_PAL_COLORS);
409     ok(hbmp != 0, "CreateDIBitmap failed\n");
410     ok_err(0xbadbad00);
411     DeleteObject(hbmp);
412 
413 
414 }
415 
416 void
417 Test_CreateDIBitmap_CBM_CREATDIB(void)
418 {
419     HBITMAP hbmp, hbmpOld;
420     HDC hdc;
421     BITMAPINFO bmi =
422         {{sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 1, 0}, {{0,1,2,3}}};
423     BYTE ajBits[10] = {0,1,2,3,4,5,6,7,8,9};
424     BITMAP bitmap;
425     struct
426     {
427         BITMAPINFOHEADER bmiHeader;
428         WORD wColors[4];
429     } bmiRLE =
430     {
431         {sizeof(BITMAPINFOHEADER), 8, 2, 1, 8, BI_RLE8, 20, 1, 1, 4, 0},
432         {0, 1, 2, 7}
433     };
434     BYTE ajBitsRLE[] = {4,0,   0,2,0,1,0,2,3,1,   2,1, 2,2,   1,3,1,0,1,2, };
435 
436     hdc = CreateCompatibleDC(0);
437     if (hdc == NULL)
438     {
439         ok(0, "CreateCompatibleDC failed. Skipping tests!\n");
440         return;
441     }
442 
443     SetLastError(0xbadbad00);
444     hbmp = CreateDIBitmap(hdc, NULL, CBM_CREATDIB, ajBits, NULL, DIB_RGB_COLORS);
445     ok(hbmp == 0, "CreateDIBitmap should fail.\n");
446     ok_int(GetLastError(), 0xbadbad00);
447 
448     hbmp = CreateDIBitmap(hdc, NULL, CBM_CREATDIB, ajBits, &bmi, DIB_RGB_COLORS);
449     ok(hbmp != 0, "CreateDIBitmap failed.\n");
450 
451     ok_long(GetObject(hbmp, sizeof(DIBSECTION), &bitmap), sizeof(BITMAP));
452     ok_int(bitmap.bmType, 0);
453     ok_int(bitmap.bmWidth, 4);
454     ok_int(bitmap.bmHeight, 4);
455     ok_int(bitmap.bmWidthBytes, 4);
456     ok_int(bitmap.bmPlanes, 1);
457     ok_int(bitmap.bmBitsPixel, 8);
458     ok_ptr(bitmap.bmBits, 0);
459 
460     hbmpOld = SelectObject(hdc, hbmp);
461     ok(hbmpOld != NULL, "Couldn't select the bitmap.\n");
462 
463     /* Copy it on a dib section */
464     memset(gpDIB32, 0x77, sizeof(*gpDIB32));
465     ok_long(BitBlt(ghdcDIB32, 0, 0, 4, 4, hdc, 0, 0, SRCCOPY), 1);
466     ok_long((*gpDIB32)[0][0], 0x20100);
467     ok_long((*gpDIB32)[0][1], 0x20100);
468     ok_long((*gpDIB32)[0][2], 0x20100);
469     ok_long((*gpDIB32)[0][3], 0x20100);
470 
471     SelectObject(hdc, hbmpOld);
472     DeleteObject(hbmp);
473 
474     hbmp = CreateDIBitmap(hdc, NULL, CBM_CREATDIB | CBM_INIT, ajBits, &bmi, DIB_PAL_COLORS);
475     ok(hbmp != 0, "CreateDIBitmap failed.\n");
476 
477     ok_long(GetObject(hbmp, sizeof(DIBSECTION), &bitmap), sizeof(BITMAP));
478     ok_int(bitmap.bmType, 0);
479     ok_int(bitmap.bmWidth, 4);
480     ok_int(bitmap.bmHeight, 4);
481     ok_int(bitmap.bmWidthBytes, 4);
482     ok_int(bitmap.bmPlanes, 1);
483     ok_int(bitmap.bmBitsPixel, 8);
484     ok_ptr(bitmap.bmBits, 0);
485 
486     /* Even with CBM_INIT and lpbmih != 0, pbmi is used for the dimensions */
487     hbmp = CreateDIBitmap(hdc, &bmiRLE.bmiHeader, CBM_CREATDIB | CBM_INIT, ajBits, &bmi, DIB_PAL_COLORS);
488     ok(hbmp != 0, "CreateDIBitmap failed.\n");
489 
490     ok_long(GetObject(hbmp, sizeof(DIBSECTION), &bitmap), sizeof(BITMAP));
491     ok_int(bitmap.bmType, 0);
492     ok_int(bitmap.bmWidth, 4);
493     ok_int(bitmap.bmHeight, 4);
494     ok_int(bitmap.bmWidthBytes, 4);
495     ok_int(bitmap.bmPlanes, 1);
496     ok_int(bitmap.bmBitsPixel, 8);
497     ok_ptr(bitmap.bmBits, 0);
498 
499     hbmpOld = SelectObject(hdc, hbmp);
500     ok(hbmpOld != NULL, "Couldn't select the bitmap.\n");
501 
502     /* Copy it on a dib section */
503     memset(gpDIB32, 0x77, sizeof(*gpDIB32));
504     ok_long(BitBlt(ghdcDIB32, 0, 0, 4, 4, hdc, 0, 0, SRCCOPY), 1);
505     ok_long((*gpDIB32)[0][0], 0);
506     ok_long((*gpDIB32)[0][1], 0);
507     ok_long((*gpDIB32)[0][2], 0);
508     ok_long((*gpDIB32)[0][3], 0);
509 
510     SelectObject(hdc, hbmpOld);
511     DeleteObject(hbmp);
512 
513     hbmp = CreateDIBitmap(hdc, NULL, CBM_CREATDIB, ajBitsRLE, (PVOID)&bmiRLE, DIB_PAL_COLORS);
514     ok(hbmp == 0, "CreateDIBitmap should fail.\n");
515     hbmp = CreateDIBitmap(hdc, NULL, CBM_INIT | CBM_CREATDIB, ajBitsRLE, (PVOID)&bmiRLE, DIB_PAL_COLORS);
516     ok(hbmp == 0, "CreateDIBitmap should fail.\n");
517 
518     /* Check if a 0 pixel bitmap results in the DEFAULT_BITMAP being returned */
519     bmi.bmiHeader.biWidth = 0;
520     bmi.bmiHeader.biHeight = 4;
521     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_CREATDIB, ajBits, &bmi, DIB_PAL_COLORS);
522     ok(hbmp == GetStockObject(21), "CreateDIBitmap didn't return the default bitmap.\n");
523     bmi.bmiHeader.biWidth = 23;
524     bmi.bmiHeader.biHeight = 0;
525     hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_CREATDIB, ajBits, &bmi, DIB_PAL_COLORS);
526     ok(hbmp == GetStockObject(21), "CreateDIBitmap didn't return the default bitmap.\n");
527 
528     DeleteDC(hdc);
529 }
530 
531 START_TEST(CreateDIBitmap)
532 {
533     InitStuff();
534     Test_CreateDIBitmap_Params();
535     Test_CreateDIBitmap1();
536     Test_CreateDIBitmap_DIB_PAL_COLORS();
537     Test_CreateDIBitmap_RLE8();
538     Test_CreateDIBitmap_CBM_CREATDIB();
539 }
540 
541