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 #include <pseh/pseh2.h> 13 14 #define CBM_CREATDIB 2 15 16 #define INVALID_POINTER ((PVOID)(ULONG_PTR)0xC0000000C0000000ULL) 17 18 BOOL 19 GetExpected( 20 DWORD *pdwError, 21 HDC hdc, 22 const BITMAPINFOHEADER *lpbmih, 23 DWORD fdwInit, 24 const VOID *lpbInit, 25 const BITMAPINFO *lpbmi, 26 UINT fuUsage) 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 } 101 102 103 void 104 Test_CreateDIBitmap_Params(void) 105 { 106 HBITMAP hbmp; 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 114 hdc = CreateCompatibleDC(0); 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 120 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, NULL, &bmi, DIB_PAL_COLORS); 121 ok(hbmp != 0, "\n"); 122 123 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, NULL, NULL, DIB_PAL_COLORS); 124 ok(hbmp != 0, "\n"); 125 126 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, 0, INVALID_POINTER, &bmi, DIB_PAL_COLORS); 127 ok(hbmp != 0, "\n"); 128 129 hbmp = CreateDIBitmap(NULL, &bmi.bmiHeader, CBM_INIT, NULL, &bmi, DIB_PAL_COLORS); 130 ok(hbmp != 0, "\n"); 131 132 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, NULL, &bmiBroken, DIB_PAL_COLORS); 133 ok(hbmp != 0, "\n"); 134 135 hbmp = CreateDIBitmap(NULL, NULL, 2, NULL, &bmi, 0); 136 ok(hbmp != 0, "\n"); 137 138 SetLastError(0xbadbad00); 139 hbmp = CreateDIBitmap(hdc, NULL, CBM_INIT, ajBits, &bmi, DIB_PAL_COLORS); 140 ok(hbmp == 0, "\n"); 141 ok_err(ERROR_INVALID_PARAMETER); 142 143 SetLastError(0xbadbad00); 144 hbmp = CreateDIBitmap(hdc, NULL, CBM_INIT, NULL, &bmiBroken, DIB_PAL_COLORS); 145 ok(hbmp == 0, "\n"); 146 ok_err(ERROR_INVALID_PARAMETER); 147 148 SetLastError(0xbadbad00); 149 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, ajBits, &bmi, 2); 150 ok(hbmp == 0, "\n"); 151 ok_err(ERROR_INVALID_PARAMETER); 152 153 SetLastError(0xbadbad00); 154 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, ajBits, NULL, DIB_PAL_COLORS); 155 ok(hbmp == 0, "\n"); 156 ok_err(0xbadbad00); 157 158 SetLastError(0xbadbad00); 159 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, INVALID_POINTER, &bmi, DIB_PAL_COLORS); 160 ok(hbmp == 0, "\n"); 161 ok_err(0xbadbad00); 162 163 SetLastError(0xbadbad00); 164 _SEH2_TRY 165 { 166 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, 0, ajBits, INVALID_POINTER, DIB_PAL_COLORS); 167 } 168 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 169 { 170 hbmp = (HBITMAP)-1; 171 } 172 _SEH2_END; 173 ok(hbmp == (HBITMAP)-1, "\n"); 174 ok_err(0xbadbad00); 175 176 SetLastError(0xbadbad00); 177 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, NULL, NULL, 5); 178 ok(hbmp == 0, "\n"); 179 ok_err(ERROR_INVALID_PARAMETER); 180 181 SetLastError(0xbadbad00); 182 hbmp = CreateDIBitmap((HDC)-1, &bmi.bmiHeader, CBM_INIT, NULL, &bmi, DIB_PAL_COLORS); 183 ok(hbmp == 0, "\n"); 184 ok_err(0xbadbad00); 185 186 SetLastError(0xbadbad00); 187 hbmp = CreateDIBitmap(hdc, &bmiBroken.bmiHeader, CBM_INIT, NULL, &bmi, DIB_PAL_COLORS); 188 ok(hbmp == 0, "\n"); 189 ok_err(ERROR_INVALID_PARAMETER); 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 220 _SEH2_TRY 221 { 222 hbmp = CreateDIBitmap(ahdc[i1], apbih[i2], afInitf[i3], apvBits[i4], apbmi[i5], aiUsage[i6]); 223 } 224 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 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 } 256 257 void 258 Test_CreateDIBitmap_DIB_PAL_COLORS(void) 259 { 260 struct 261 { 262 BITMAPINFOHEADER bmiHeader; 263 WORD bmiColors[8]; 264 } bmibuffer; 265 BITMAPINFO *pbmi = (PVOID)&bmibuffer; 266 HBITMAP hbmp; 267 ULONG bits[16] = {0}; 268 HDC hdc; 269 HPALETTE hpalOld; 270 USHORT i; 271 272 hdc = CreateCompatibleDC(0); 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 */ 280 pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 281 pbmi->bmiHeader.biWidth = 2; 282 pbmi->bmiHeader.biHeight = -2; 283 pbmi->bmiHeader.biPlanes = 1; 284 pbmi->bmiHeader.biBitCount = 8; 285 pbmi->bmiHeader.biCompression = BI_RGB; 286 pbmi->bmiHeader.biSizeImage = 0; 287 pbmi->bmiHeader.biXPelsPerMeter = 1; 288 pbmi->bmiHeader.biYPelsPerMeter = 1; 289 pbmi->bmiHeader.biClrUsed = 8; 290 pbmi->bmiHeader.biClrImportant = 0; 291 292 for( i = 0; i < 8; i++ ) 293 { 294 bmibuffer.bmiColors[i] = i; 295 } 296 297 /* Create the bitmap */ 298 hbmp = CreateDIBitmap(hdc, &pbmi->bmiHeader, CBM_INIT, bits, pbmi, DIB_PAL_COLORS); 299 ok(hbmp != 0, "failed\n"); 300 301 SelectObject(hdc, hbmp); 302 303 304 } 305 306 void 307 Test_CreateDIBitmap1(void) 308 { 309 BITMAPINFO bmi; 310 HBITMAP hbmp; 311 BITMAP bitmap; 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; 324 bmi.bmiHeader.biCompression = BI_RGB; 325 bmi.bmiHeader.biSizeImage = 0; 326 bmi.bmiHeader.biXPelsPerMeter = 1; 327 bmi.bmiHeader.biYPelsPerMeter = 1; 328 bmi.bmiHeader.biClrUsed = 0; 329 bmi.bmiHeader.biClrImportant = 0; 330 331 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_INIT, bits, &bmi, DIB_RGB_COLORS); 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); 345 bmi.bmiHeader.biCompression = BI_RLE8; 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 } 365 366 void Test_CreateDIBitmap_RLE8() 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; 380 HBITMAP hbmp; 381 382 hdc = CreateCompatibleDC(0); 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); 388 DeleteObject(hbmp); 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); 394 DeleteObject(hbmp); 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); 400 DeleteObject(hbmp); 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); 413 DeleteObject(hbmp); 414 415 416 } 417 418 void 419 Test_CreateDIBitmap_CBM_CREATDIB(void) 420 { 421 HBITMAP hbmp, hbmpOld; 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}; 426 BITMAP bitmap; 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 438 hdc = CreateCompatibleDC(0); 439 if (hdc == NULL) 440 { 441 ok(0, "CreateCompatibleDC failed. Skipping tests!\n"); 442 return; 443 } 444 445 SetLastError(0xbadbad00); 446 hbmp = CreateDIBitmap(hdc, NULL, CBM_CREATDIB, ajBits, NULL, DIB_RGB_COLORS); 447 ok(hbmp == 0, "CreateDIBitmap should fail.\n"); 448 ok_int(GetLastError(), 0xbadbad00); 449 450 hbmp = CreateDIBitmap(hdc, NULL, CBM_CREATDIB, ajBits, &bmi, DIB_RGB_COLORS); 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 462 hbmpOld = SelectObject(hdc, hbmp); 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 473 SelectObject(hdc, hbmpOld); 474 DeleteObject(hbmp); 475 476 hbmp = CreateDIBitmap(hdc, NULL, CBM_CREATDIB | CBM_INIT, ajBits, &bmi, DIB_PAL_COLORS); 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 501 hbmpOld = SelectObject(hdc, hbmp); 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 514 SelectObject(hdc, hbmpOld); 515 DeleteObject(hbmp); 516 517 hbmp = CreateDIBitmap(hdc, NULL, CBM_CREATDIB, ajBitsRLE, (PVOID)&bmiRLE, DIB_PAL_COLORS); 518 ok(hbmp == 0, "CreateDIBitmap should fail.\n"); 519 hbmp = CreateDIBitmap(hdc, NULL, CBM_INIT | CBM_CREATDIB, ajBitsRLE, (PVOID)&bmiRLE, DIB_PAL_COLORS); 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; 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 bmi.bmiHeader.biWidth = 23; 528 bmi.bmiHeader.biHeight = 0; 529 hbmp = CreateDIBitmap(hdc, &bmi.bmiHeader, CBM_CREATDIB, ajBits, &bmi, DIB_PAL_COLORS); 530 ok(hbmp == GetStockObject(21), "CreateDIBitmap didn't return the default bitmap.\n"); 531 532 DeleteDC(hdc); 533 } 534 535 START_TEST(CreateDIBitmap) 536 { 537 InitStuff(); 538 Test_CreateDIBitmap_Params(); 539 Test_CreateDIBitmap1(); 540 Test_CreateDIBitmap_DIB_PAL_COLORS(); 541 Test_CreateDIBitmap_RLE8(); 542 Test_CreateDIBitmap_CBM_CREATDIB(); 543 } 544 545