@@ -271,11 +271,25 @@ void Test_GetDIBits()
271
271
272
272
/* Test with different biBitCount set */
273
273
pbi -> bmiHeader .biBitCount = 4 ;
274
- pbi -> bmiHeader .biSizeImage = 0 ;
274
+ pbi -> bmiHeader .biSizeImage = 1 ;
275
275
ok_int (GetDIBits (hdcScreen , hbmp , 0 , 0 , NULL , pbi , DIB_RGB_COLORS ), 1 );
276
276
ok_int (pbi -> bmiHeader .biSizeImage , 36 );
277
277
ok_int (pbi -> bmiHeader .biBitCount , 4 );
278
278
279
+ /* Test with different biBitCount set */
280
+ pbi -> bmiHeader .biBitCount = 8 ;
281
+ pbi -> bmiHeader .biSizeImage = 1000 ;
282
+ ok_int (GetDIBits (hdcScreen , hbmp , 0 , 0 , NULL , pbi , DIB_RGB_COLORS ), 1 );
283
+ ok_int (pbi -> bmiHeader .biSizeImage , 60 );
284
+ ok_int (pbi -> bmiHeader .biBitCount , 8 );
285
+
286
+ /* Test with invalid biBitCount set */
287
+ pbi -> bmiHeader .biBitCount = 123 ;
288
+ pbi -> bmiHeader .biSizeImage = -12 ;
289
+ ok_int (GetDIBits (hdcScreen , hbmp , 0 , 0 , NULL , pbi , DIB_RGB_COLORS ), 0 );
290
+ ok_int (pbi -> bmiHeader .biSizeImage , -12 );
291
+ ok_int (pbi -> bmiHeader .biBitCount , 123 );
292
+
279
293
/* Set bitmap dimensions */
280
294
ok_int (SetBitmapDimensionEx (hbmp , 110 , 220 , NULL ), 1 );
281
295
ZeroMemory (pbi , bisize );
@@ -320,16 +334,21 @@ void Test_GetDIBits()
320
334
ok_int (pbi -> bmiHeader .biCompression , 0 );
321
335
ok_int (pbi -> bmiHeader .biSizeImage , 0 );
322
336
323
- /* Get the bitmap bits */
337
+ /* Get the bitmap info */
324
338
pbi -> bmiHeader .biSize = sizeof (BITMAPINFOHEADER );
325
339
pbi -> bmiHeader .biWidth = 4 ;
326
340
pbi -> bmiHeader .biHeight = 4 ;
327
- pbi -> bmiHeader .biPlanes = 1 ;
341
+ pbi -> bmiHeader .biPlanes = 3 ;
328
342
pbi -> bmiHeader .biBitCount = 32 ;
329
343
pbi -> bmiHeader .biCompression = BI_RGB ;
330
344
ok_int (GetDIBits (hdcScreen , hbmp , 0 , 5 , NULL , pbi , DIB_RGB_COLORS ), 1 );
345
+ ok_int (pbi -> bmiHeader .biSizeImage , 64 );
346
+ ok_int (pbi -> bmiHeader .biPlanes , 1 );
331
347
pbi -> bmiHeader .biWidth = 0 ;
332
348
ok_int (GetDIBits (hdcScreen , hbmp , 0 , 5 , NULL , pbi , DIB_RGB_COLORS ), 0 );
349
+ pbi -> bmiHeader .biWidth = 2 ;
350
+ ok_int (GetDIBits (hdcScreen , hbmp , 0 , 5 , NULL , pbi , DIB_RGB_COLORS ), 1 );
351
+ ok_int (pbi -> bmiHeader .biSizeImage , 32 );
333
352
pbi -> bmiHeader .biWidth = -3 ;
334
353
ok_int (GetDIBits (hdcScreen , hbmp , 0 , 5 , NULL , pbi , DIB_RGB_COLORS ), 0 );
335
354
pbi -> bmiHeader .biWidth = 4 ;
@@ -343,12 +362,24 @@ void Test_GetDIBits()
343
362
pbi -> bmiHeader .biPlanes = 23 ;
344
363
ok_int (GetDIBits (hdcScreen , hbmp , 0 , 5 , NULL , pbi , DIB_RGB_COLORS ), 1 );
345
364
ok_int (pbi -> bmiHeader .biPlanes , 1 );
365
+ SetLastError (0xdeadbabe );
366
+ ok_int (GetDIBits ((HDC )0xff00ff00 , hbmp , 0 , 5 , NULL , pbi , DIB_RGB_COLORS ), 0 );
367
+ ok_err (0x57 );
368
+ SetLastError (0xdeadbabe );
369
+ ok_int (GetDIBits (hdcScreen , (HBITMAP )0xff00ff00 , 0 , 5 , NULL , pbi , DIB_RGB_COLORS ), 0 );
370
+ ok_err (0xdeadbabe );
371
+ SetLastError (0xdeadbabe );
372
+ ok_int (GetDIBits ((HDC )0xff00ff00 , (HBITMAP )0xff00ff00 , 0 , 5 , NULL , pbi , DIB_RGB_COLORS ), 0 );
373
+ ok_err (0x57 );
374
+ SetLastError (0xdeadbabe );
375
+ ok_int (GetDIBits (NULL , hbmp , 0 , 5 , NULL , pbi , DIB_RGB_COLORS ), 0 );
376
+ ok_err (0x57 );
377
+
346
378
pbi -> bmiHeader .biCompression = BI_JPEG ;
347
379
ok_int (GetDIBits (hdcScreen , hbmp , 0 , 5 , NULL , pbi , DIB_RGB_COLORS ), 0 );
348
380
pbi -> bmiHeader .biCompression = BI_PNG ;
349
381
ok_int (GetDIBits (hdcScreen , hbmp , 0 , 5 , NULL , pbi , DIB_RGB_COLORS ), 0 );
350
382
351
-
352
383
/* Get the bitmap bits */
353
384
pbi -> bmiHeader .biSize = sizeof (BITMAPINFOHEADER );
354
385
pbi -> bmiHeader .biWidth = 4 ;
@@ -364,10 +395,22 @@ void Test_GetDIBits()
364
395
cjSizeImage = ((pbi -> bmiHeader .biWidth * pbi -> bmiHeader .biBitCount + 31 ) / 32 ) * 4 * pbi -> bmiHeader .biHeight ;
365
396
pvBits = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY , 512 );
366
397
ok_int (GetDIBits (hdcScreen , hbmp , 0 , 4 , pvBits , pbi , DIB_RGB_COLORS ), 4 );
398
+ ok_int (pbi -> bmiHeader .biSize , sizeof (BITMAPINFOHEADER ));
399
+ ok_int (pbi -> bmiHeader .biWidth , 4 );
400
+ ok_int (pbi -> bmiHeader .biHeight , 4 );
401
+ ok_int (pbi -> bmiHeader .biPlanes , 1 );
402
+ ok_int (pbi -> bmiHeader .biBitCount , 32 );
403
+ ok_int (pbi -> bmiHeader .biCompression , BI_RGB );
404
+ ok_int (pbi -> bmiHeader .biSizeImage , 64 );
405
+ ok_int (pbi -> bmiHeader .biXPelsPerMeter , 0 );
406
+ ok_int (pbi -> bmiHeader .biYPelsPerMeter , 0 );
407
+ ok_int (pbi -> bmiHeader .biClrUsed , 0 );
408
+ ok_int (pbi -> bmiHeader .biClrImportant , 0 );
367
409
368
410
/* Set biBitCount to 0 */
369
411
pbi -> bmiHeader .biBitCount = 0 ;
370
412
ok_int (GetDIBits (hdcScreen , hbmp , 0 , 4 , pvBits , pbi , DIB_RGB_COLORS ), 0 );
413
+ ok_int (GetDIBits (hdcScreen , hbmp , 0 , 4 , (PVOID )(LONG_PTR )- 1 , pbi , DIB_RGB_COLORS ), 0 );
371
414
ok_int (GetDIBits (hdcScreen , hbmp , 0 , 4 , NULL , pbi , DIB_RGB_COLORS ), 1 );
372
415
ok_int (GetDIBits (NULL , hbmp , 0 , 4 , NULL , pbi , DIB_RGB_COLORS ), 0 );
373
416
@@ -381,6 +424,10 @@ void Test_GetDIBits()
381
424
pbi -> bmiHeader .biWidth = 3 ;
382
425
ok_int (GetDIBits (hdcScreen , hbmp , 0 , 4 , pvBits , pbi , DIB_RGB_COLORS ), 4 );
383
426
427
+ /* Try invalid biBitCount */
428
+ pbi -> bmiHeader .biBitCount = 17 ;
429
+ ok_int (GetDIBits (hdcScreen , hbmp , 0 , 4 , pvBits , pbi , DIB_RGB_COLORS ), 0 );
430
+
384
431
/* Set only biBitCount and pjInit */
385
432
ZeroMemory (pbi , bisize );
386
433
pbi -> bmiHeader .biSize = sizeof (BITMAPINFOHEADER );
@@ -405,19 +452,19 @@ void Test_GetDIBits()
405
452
pbi -> bmiHeader .biSizeImage = 0 ;
406
453
ok_int (GetDIBits (hdcScreen , hbmp , 0 , 0 , NULL , pbi , DIB_RGB_COLORS ), 0 );
407
454
455
+ /* Calculate bitmap size and allocate a buffer */
408
456
cjSizeImage = ((pbi -> bmiHeader .biWidth * pbi -> bmiHeader .biBitCount + 31 ) / 32 ) * 4 * pbi -> bmiHeader .biHeight ;
457
+ ok_int (cjSizeImage , 20 );
409
458
pvBits = HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY , cjSizeImage );
410
459
460
+ /* Test using a compatible DC */
411
461
hdcMem = CreateCompatibleDC (0 );
412
462
ok (hdcMem != 0 , "CreateCompatibleDC failed, skipping tests\n" );
413
463
if (hdcMem == NULL ) return ;
464
+ ok_int (GetDIBits (hdcMem , hbmp , 0 , 4 , pvBits , pbi , DIB_RGB_COLORS ), 0 );
465
+ ok_int (GetDIBits (hdcMem , ghbmpDIB4 , 0 , 4 , pvBits , pbi , DIB_RGB_COLORS ), 4 );
414
466
415
- // FIXME: broken
416
- //ok(SelectObject(hdcMem, ghbmpDIB4) != 0, "Failed to select 4bpp DIB %p into DC %p\n", ghbmpDIB4, hdcMem);;
417
- //ok_int(GetDIBits(hdcMem, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
418
- //ok_int(GetDIBits(hdcMem, ghbmpDIB4, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 3);
419
-
420
-
467
+ HeapFree (GetProcessHeap (), 0 , pvBits );
421
468
DeleteDC (hdcMem );
422
469
ReleaseDC (NULL , hdcScreen );
423
470
}
0 commit comments