ReactOS 0.4.15-dev-5666-gc548b97
GetDIBits.c File Reference
#include "precomp.h"
#include "init.h"
Include dependency graph for GetDIBits.c:

Go to the source code of this file.

Functions

void Test_GetDIBits_xBpp (ULONG cBitsPixel)
 
void Test_GetDIBits ()
 
void Test_GetDIBits_BI_BITFIELDS ()
 
 START_TEST (GetDIBits)
 

Function Documentation

◆ START_TEST()

START_TEST ( GetDIBits  )

Definition at line 473 of file GetDIBits.c.

474{
475 //getchar();
476 InitStuff();
484}
void Test_GetDIBits_xBpp(ULONG cBitsPixel)
Definition: GetDIBits.c:13
void Test_GetDIBits()
Definition: GetDIBits.c:97
BOOL InitStuff(void)
Definition: init.c:95

◆ Test_GetDIBits()

void Test_GetDIBits ( )

Definition at line 97 of file GetDIBits.c.

98{
99 HDC hdcScreen, hdcMem;
102 DWORD bisize;
104 PBITMAPV5HEADER pbV5Header;
105 INT ScreenBpp;
106 DWORD ajBits[100] = {0xff, 0x00, 0xcc, 0xf0, 0x0f};
107 PVOID pvBits;
108 ULONG cjSizeImage;
109
110 bisize = sizeof(BITMAPV5HEADER) + 256 * sizeof(DWORD);
111 pbi = malloc(bisize);
112 pbch = (PVOID)pbi;
113 pbV5Header = (PVOID)pbi;
114
115 hdcScreen = GetDC(NULL);
116 ok(hdcScreen != 0, "GetDC failed, skipping tests\n");
117 if (hdcScreen == NULL) return;
118
119 hbmp = CreateCompatibleBitmap(hdcScreen, 16, 16);
120 ok(hbmp != NULL, "CreateCompatibleBitmap failed\n");
121
122 /* misc */
124 ok(GetDIBits(0, 0, 0, 0, NULL, NULL, 0) == 0, "\n");
126
128 ok(GetDIBits((HDC)2345, 0, 0, 0, NULL, NULL, 0) == 0, "\n");
130
132 ok(GetDIBits((HDC)2345, hbmp, 0, 0, NULL, NULL, 0) == 0, "\n");
134
136 ok(GetDIBits((HDC)2345, hbmp, 0, 15, NULL, pbi, 0) == 0, "\n");
138
139
140
141 /* null hdc */
143 ZeroMemory(pbi, bisize);
144 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
145 ok(GetDIBits(NULL, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS) == 0, "\n");
147
148 /* null bitmap */
150 ZeroMemory(pbi, bisize);
151 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
152 ok(GetDIBits(hdcScreen, NULL, 0, 15, NULL, pbi, DIB_RGB_COLORS) == 0, "\n");
154
155 /* 0 scan lines */
157 ZeroMemory(pbi, bisize);
158 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
159 ok(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS) > 0, "\n");
161
162 /* null bitmap info - crashes XP*/
163 //SetLastError(ERROR_SUCCESS);
164 //ok(GetDIBits(hdcScreen, NULL, 0, 15, NULL, NULL, DIB_RGB_COLORS) == 0);
165 //ok(GetLastError() == ERROR_INVALID_PARAMETER);
166
167 /* bad bmi colours (uUsage) */
168 SetLastError(0);
169 ZeroMemory(pbi, bisize);
170 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
171 ok(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, 100) == 0, "\n");
173 ok(pbi->bmiHeader.biWidth == 0, "\n");
174 ok(pbi->bmiHeader.biHeight == 0, "\n");
175 ok(pbi->bmiHeader.biBitCount == 0, "\n");
176 ok(pbi->bmiHeader.biSizeImage == 0, "\n");
177
178 /* basic call */
180 ZeroMemory(pbi, bisize);
181 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
182 ok(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS) > 0, "\n");
184 ScreenBpp = GetDeviceCaps(hdcScreen, BITSPIXEL);
185 ok(pbi->bmiHeader.biWidth == 16, "\n");
186 ok(pbi->bmiHeader.biHeight == 16, "\n");
187 ok(pbi->bmiHeader.biBitCount == ScreenBpp, "\n");
188 ok(pbi->bmiHeader.biSizeImage == (16 * 16) * (ScreenBpp / 8), "\n");
189
190 /* Test if COREHEADER is supported */
191 ZeroMemory(pbi, bisize);
192 pbi->bmiHeader.biSize = sizeof(BITMAPCOREHEADER);
193 ok_int(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS), 1);
194 ok_int(pbi->bmiHeader.biSize, sizeof(BITMAPCOREHEADER));
195 ok_int(pbch->bcWidth, 16);
196 ok_int(pbch->bcHeight, 16);
197 ok_int(pbch->bcPlanes, 1);
198 //ok_int(pbch->bcBitCount, ScreenBpp > 16 ? 24 : ScreenBpp); // fails on XP with screenbpp == 16
199
200 /* Test different header sizes */
201 ZeroMemory(pbi, bisize);
202 pbi->bmiHeader.biSize = sizeof(BITMAPCOREHEADER) + 4;
203 ok_int(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS), 0);
204
205 ZeroMemory(pbi, bisize);
206 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) + 4;
207 ok_int(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS), 1);
208
209 ZeroMemory(pbi, bisize);
210 pbi->bmiHeader.biSize = sizeof(BITMAPV4HEADER);
211 ok_int(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS), 1);
212
213 ZeroMemory(pbi, bisize);
214 pbi->bmiHeader.biSize = sizeof(BITMAPV4HEADER) + 4;
215 ok_int(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS), 1);
216
217 ZeroMemory(pbi, bisize);
218 pbi->bmiHeader.biSize = sizeof(BITMAPV5HEADER);
219 ok_int(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS), 1);
220
221 ZeroMemory(pbi, bisize);
222 pbi->bmiHeader.biSize = sizeof(BITMAPV5HEADER) + 4;
223 ok_int(GetDIBits(hdcScreen, hbmp, 0, 15, NULL, pbi, DIB_RGB_COLORS), 1);
224 ok_int(pbV5Header->bV5RedMask, 0);
225 ok_int(pbV5Header->bV5GreenMask, 0);
226 ok_int(pbV5Header->bV5BlueMask, 0);
227 ok_int(pbV5Header->bV5AlphaMask, 0);
228 ok_int(pbV5Header->bV5CSType, 0);
229 // CIEXYZTRIPLE bV5Endpoints;
230 ok_int(pbV5Header->bV5GammaRed, 0);
231 ok_int(pbV5Header->bV5GammaGreen, 0);
232 ok_int(pbV5Header->bV5GammaBlue, 0);
233 ok_int(pbV5Header->bV5Intent, 0);
234 ok_int(pbV5Header->bV5ProfileData, 0);
235 ok_int(pbV5Header->bV5ProfileSize, 0);
236 ok_int(pbV5Header->bV5Reserved, 0);
237
238 ZeroMemory(pbi, bisize);
239 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
240 ok_int(GetDIBits(hdcScreen, hbmp, 234, 43, NULL, pbi, DIB_RGB_COLORS), 1);
241
243
244 /* Test a mono bitmap */
245 hbmp = CreateBitmap(13, 7, 1, 1, ajBits);
246 ok(hbmp != 0, "failed to create bitmap\n");
247 ZeroMemory(pbi, bisize);
248 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
249 ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 1);
250 ok_int(pbi->bmiHeader.biWidth, 13);
251 ok_int(pbi->bmiHeader.biHeight, 7);
252 ok_int(pbi->bmiHeader.biBitCount, 1);
253 ok_int(pbi->bmiHeader.biSizeImage, 28);
254
255 /* Test with values set, except biSizeImage */
256 pbi->bmiHeader.biSizeImage = 0;
257 ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 1);
258 ok_int(pbi->bmiHeader.biSizeImage, 28);
259
260 /* Test with different biWidth set */
261 pbi->bmiHeader.biWidth = 17;
262 pbi->bmiHeader.biHeight = 3;
263 pbi->bmiHeader.biSizeImage = 0;
264 ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 1);
265 ok_int(pbi->bmiHeader.biSizeImage, 12);
266 ok_int(pbi->bmiHeader.biWidth, 17);
267 ok_int(pbi->bmiHeader.biHeight, 3);
268
269 /* Test with different biBitCount set */
270 pbi->bmiHeader.biBitCount = 4;
271 pbi->bmiHeader.biSizeImage = 1;
272 ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 1);
273 ok_int(pbi->bmiHeader.biSizeImage, 36);
274 ok_int(pbi->bmiHeader.biBitCount, 4);
275
276 /* Test with different biBitCount set */
277 pbi->bmiHeader.biBitCount = 8;
278 pbi->bmiHeader.biSizeImage = 1000;
279 ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 1);
280 ok_int(pbi->bmiHeader.biSizeImage, 60);
281 ok_int(pbi->bmiHeader.biBitCount, 8);
282
283 /* Test with invalid biBitCount set */
284 pbi->bmiHeader.biBitCount = 123;
285 pbi->bmiHeader.biSizeImage = -12;
286 ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 0);
287 ok_int(pbi->bmiHeader.biSizeImage, -12);
288 ok_int(pbi->bmiHeader.biBitCount, 123);
289
290 /* Set bitmap dimensions */
291 ok_int(SetBitmapDimensionEx(hbmp, 110, 220, NULL), 1);
292 ZeroMemory(pbi, bisize);
293 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
294 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
295 ok_int(pbi->bmiHeader.biXPelsPerMeter, 0);
296 ok_int(pbi->bmiHeader.biYPelsPerMeter, 0);
297
298 /* Set individual values */
299 ZeroMemory(pbi, bisize);
300 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
301 pbi->bmiHeader.biWidth = 12;
302 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
303 ok_int(pbi->bmiHeader.biWidth, 13);
304 ok_int(pbi->bmiHeader.biSizeImage, 28);
305
306 ZeroMemory(pbi, bisize);
307 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
308 pbi->bmiHeader.biSizeImage = 123;
309 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
310
311 ZeroMemory(pbi, bisize);
312 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
313 pbi->bmiHeader.biCompression = BI_RGB;
314 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
315
316 /* Set only biBitCount */
317 ZeroMemory(pbi, bisize);
318 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
319 pbi->bmiHeader.biBitCount = 5;
320 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
321 pbi->bmiHeader.biBitCount = 1;
322 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
323 pbi->bmiHeader.biBitCount = 8;
324 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
325 pbi->bmiHeader.biBitCount = 32;
326 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
327 ok_int(pbi->bmiHeader.biWidth, 0);
328 ok_int(pbi->bmiHeader.biHeight, 0);
329 ok_int(pbi->bmiHeader.biPlanes, 0);
330 ok_int(pbi->bmiHeader.biBitCount, 32);
331 ok_int(pbi->bmiHeader.biCompression, 0);
332 ok_int(pbi->bmiHeader.biSizeImage, 0);
333
334 /* Get the bitmap info */
335 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
336 pbi->bmiHeader.biWidth = 4;
337 pbi->bmiHeader.biHeight = 4;
338 pbi->bmiHeader.biPlanes = 3;
339 pbi->bmiHeader.biBitCount = 32;
340 pbi->bmiHeader.biCompression = BI_RGB;
341 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
342 ok_int(pbi->bmiHeader.biSizeImage, 64);
343 ok_int(pbi->bmiHeader.biPlanes, 1);
344 pbi->bmiHeader.biWidth = 0;
345 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
346 pbi->bmiHeader.biWidth = 2;
347 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
348 ok_int(pbi->bmiHeader.biSizeImage, 32);
349 pbi->bmiHeader.biWidth = -3;
350 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
351 pbi->bmiHeader.biWidth = 4;
352 pbi->bmiHeader.biHeight = 0;
353 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
354 pbi->bmiHeader.biHeight = -4;
355 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
356 pbi->bmiHeader.biBitCount = 31;
357 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
358 pbi->bmiHeader.biBitCount = 16;
359 pbi->bmiHeader.biPlanes = 23;
360 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 1);
361 ok_int(pbi->bmiHeader.biPlanes, 1);
362 SetLastError(0xdeadbabe);
363 ok_int(GetDIBits((HDC)UlongToHandle(0xff00ff00), hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
364 ok_err(0x57);
365 SetLastError(0xdeadbabe);
366 ok_int(GetDIBits(hdcScreen, (HBITMAP)UlongToHandle(0xff00ff00), 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
367 ok_err(0xdeadbabe);
368 SetLastError(0xdeadbabe);
369 ok_int(GetDIBits((HDC)UlongToHandle(0xff00ff00), (HBITMAP)UlongToHandle(0xff00ff00), 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
370 ok_err(0x57);
371 SetLastError(0xdeadbabe);
373 ok_err(0x57);
374
375 pbi->bmiHeader.biCompression = BI_JPEG;
376 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
377 pbi->bmiHeader.biCompression = BI_PNG;
378 ok_int(GetDIBits(hdcScreen, hbmp, 0, 5, NULL, pbi, DIB_RGB_COLORS), 0);
379
380 /* Get the bitmap bits */
381 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
382 pbi->bmiHeader.biWidth = 4;
383 pbi->bmiHeader.biHeight = 4;
384 pbi->bmiHeader.biPlanes = 1;
385 pbi->bmiHeader.biBitCount = 32;
386 pbi->bmiHeader.biCompression = BI_RGB;
387 pbi->bmiHeader.biSizeImage = 0;
388 pbi->bmiHeader.biXPelsPerMeter = 0;
389 pbi->bmiHeader.biYPelsPerMeter = 0;
390 pbi->bmiHeader.biClrUsed = 0;
391 pbi->bmiHeader.biClrImportant = 0;
392 cjSizeImage = ((pbi->bmiHeader.biWidth * pbi->bmiHeader.biBitCount + 31) / 32) * 4 * pbi->bmiHeader.biHeight;
393 pvBits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 512);
394 ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 4);
395 ok_int(pbi->bmiHeader.biSize, sizeof(BITMAPINFOHEADER));
396 ok_int(pbi->bmiHeader.biWidth, 4);
397 ok_int(pbi->bmiHeader.biHeight, 4);
398 ok_int(pbi->bmiHeader.biPlanes, 1);
399 ok_int(pbi->bmiHeader.biBitCount, 32);
400 ok_int(pbi->bmiHeader.biCompression, BI_RGB);
401 ok_int(pbi->bmiHeader.biSizeImage, 64);
402 ok_int(pbi->bmiHeader.biXPelsPerMeter, 0);
403 ok_int(pbi->bmiHeader.biYPelsPerMeter, 0);
404 ok_int(pbi->bmiHeader.biClrUsed, 0);
405 ok_int(pbi->bmiHeader.biClrImportant, 0);
406
407 /* Set biBitCount to 0 */
408 pbi->bmiHeader.biBitCount = 0;
409 ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
410 ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, (PVOID)(LONG_PTR)-1, pbi, DIB_RGB_COLORS), 0);
411 ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, NULL, pbi, DIB_RGB_COLORS), 1);
413
414 /* Try different biBitCount and biWidth */
415 pbi->bmiHeader.biBitCount = 24;
416 pbi->bmiHeader.biWidth = 3;
417 ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 4);
418
419 /* Try different biBitCount and biWidth */
420 pbi->bmiHeader.biBitCount = 24;
421 pbi->bmiHeader.biWidth = 3;
422 ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 4);
423
424 /* Try invalid biBitCount */
425 pbi->bmiHeader.biBitCount = 17;
426 ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
427
428 /* Set only biBitCount and pjInit */
429 ZeroMemory(pbi, bisize);
430 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
431 pbi->bmiHeader.biBitCount = 5;
432 ok_int(GetDIBits(hdcScreen, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
433
435 HeapFree(GetProcessHeap(), 0, pvBits);
436
437 /* Test a 4 bpp bitmap */
438 hbmp = CreateBitmap(3, 5, 1, 4, NULL);
439 ok(hbmp != 0, "failed to create bitmap\n");
440 ZeroMemory(pbi, bisize);
441 pbi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
442 ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 1);
443 ok_int(pbi->bmiHeader.biWidth, 3);
444 ok_int(pbi->bmiHeader.biHeight, 5);
445 ok_int(pbi->bmiHeader.biBitCount, 4);
446 ok_int(pbi->bmiHeader.biSizeImage, 20);
447
448 /* This does NOT work with incompatible bitmaps */
449 pbi->bmiHeader.biSizeImage = 0;
450 ok_int(GetDIBits(hdcScreen, hbmp, 0, 0, NULL, pbi, DIB_RGB_COLORS), 0);
451
452 /* Calculate bitmap size and allocate a buffer */
453 cjSizeImage = ((pbi->bmiHeader.biWidth * pbi->bmiHeader.biBitCount + 31) / 32) * 4 * pbi->bmiHeader.biHeight;
454 ok_int(cjSizeImage, 20);
455 pvBits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cjSizeImage);
456
457 /* Test using a compatible DC */
459 ok(hdcMem != 0, "CreateCompatibleDC failed, skipping tests\n");
460 if (hdcMem == NULL) return;
461 ok_int(GetDIBits(hdcMem, hbmp, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 0);
462 ok_int(GetDIBits(hdcMem, ghbmpDIB4, 0, 4, pvBits, pbi, DIB_RGB_COLORS), 4);
463
464 HeapFree(GetProcessHeap(), 0, pvBits);
466 ReleaseDC(NULL, hdcScreen);
467}
#define ok(value,...)
Definition: atltest.h:57
#define ok_err(error)
Definition: atltest.h:124
#define ok_int(expression, result)
Definition: atltest.h:134
#define UlongToHandle(ul)
Definition: basetsd.h:97
HBITMAP hbmp
#define malloc
Definition: debug_ros.c:4
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define BI_RGB
Definition: precomp.h:47
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
void * PVOID
Definition: retypes.h:9
unsigned int ULONG
Definition: retypes.h:1
HBITMAP ghbmpDIB4
Definition: init.c:7
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:92
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
int32_t INT
Definition: typedefs.h:58
HDC hdcMem
Definition: welcome.c:104
#define ZeroMemory
Definition: winbase.h:1670
_Inout_ PERBANDINFO * pbi
Definition: winddi.h:3917
#define DIB_RGB_COLORS
Definition: wingdi.h:367
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
struct tagBITMAPCOREHEADER BITMAPCOREHEADER
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define BI_JPEG
Definition: wingdi.h:38
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
#define BITSPIXEL
Definition: wingdi.h:720
#define BI_PNG
Definition: wingdi.h:39
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI SetBitmapDimensionEx(_In_ HBITMAP, _In_ int, _In_ int, _Out_opt_ LPSIZE)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

Referenced by START_TEST().

◆ Test_GetDIBits_BI_BITFIELDS()

void Test_GetDIBits_BI_BITFIELDS ( )

Definition at line 469 of file GetDIBits.c.

470{
471}

◆ Test_GetDIBits_xBpp()

void Test_GetDIBits_xBpp ( ULONG  cBitsPixel)

Definition at line 13 of file GetDIBits.c.

15{
16 UCHAR ajBuffer[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];
17 PBITMAPINFO pbmi = (PBITMAPINFO)ajBuffer;
19 ULONG cjSizeImage, cColors;
20 HDC hdc;
21
22 hdc = GetDC(0);
23 hbmp = CreateBitmap(3, 3, 1, cBitsPixel, NULL);
24
25 /* Fill in the size field */
26 ZeroMemory(pbmi, sizeof(ajBuffer));
28
29 /* Get info */
31 cjSizeImage = (((pbmi->bmiHeader.biWidth * pbmi->bmiHeader.biBitCount) + 31) & ~31) * pbmi->bmiHeader.biHeight / 8;
32 cColors = cBitsPixel <= 8 ? 1 << pbmi->bmiHeader.biBitCount : 0;
33
38 ok_int(pbmi->bmiHeader.biBitCount, cBitsPixel);
39 ok_int(pbmi->bmiHeader.biCompression, (cBitsPixel == 16) || (cBitsPixel == 32) ? BI_BITFIELDS : BI_RGB);
40 ok_int(pbmi->bmiHeader.biSizeImage, cjSizeImage);
43 ok_int(pbmi->bmiHeader.biClrUsed, cColors);
45
46// pbmi->bmiHeader.biSizeImage = 0;
47 //ok_int(GetDIBits(NULL, hbmp, 0, 0, NULL, pbmi, DIB_RGB_COLORS), 1);
48
49 /* Test a bitmap with values partly set */
50 ZeroMemory(pbmi, sizeof(ajBuffer));
55 pbmi->bmiHeader.biBitCount = 0; // keep biBitCount == 0!
62 ok_int(pbmi->bmiHeader.biBitCount, cBitsPixel);
63 ok_int(pbmi->bmiHeader.biSizeImage, cjSizeImage);
66 ok_int(pbmi->bmiHeader.biClrUsed, cColors);
68
69
70#if 0
71 /* Get info including the color table */
72 ZeroMemory(pbmi, sizeof(ajBuffer));
76
77 /* Check a different bit depth */
78 pbmi->bmiHeader.biBitCount, cBitsPixel = (cBitsPixel == 1) ? 8 : 1;
80 ok_int(pbmi->bmiHeader.biBitCount, (cBitsPixel == 1) ? 8 : 1);
81
82 /* Get the bits */
83 SetLastError(0);
84 ok_int(GetDIBits(hdc, hbmp, 0, 4, pvBits, pbmi, DIB_PAL_COLORS), 3);
85 ok_int(GetDIBits(hdc, hbmp, 3, 7, pvBits, pbmi, DIB_RGB_COLORS), 1);
86 ok_err(0);
87
90 ok_int(GetDIBits(hdc, hbmp, 0, 4, pvBits, pbmi, DIB_RGB_COLORS), 3);
91#endif
92
95}
ULONG RGBQUAD
Definition: precomp.h:50
#define BI_BITFIELDS
Definition: mmreg.h:507
HDC hdc
Definition: main.c:9
_In_ HBITMAP _In_ UINT _In_ UINT _Inout_ LPBITMAPINFO pbmi
Definition: ntgdi.h:2780
ULONG biClrImportant
Definition: precomp.h:43
USHORT biBitCount
Definition: precomp.h:37
LONG biYPelsPerMeter
Definition: precomp.h:41
ULONG biCompression
Definition: precomp.h:38
LONG biXPelsPerMeter
Definition: precomp.h:40
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
#define DIB_PAL_COLORS
Definition: wingdi.h:366
struct tagBITMAPINFO * PBITMAPINFO
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by START_TEST().