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