MCPcopy Create free account
hub / github.com/NetHack/NetHack / read_info_header

Function read_info_header

win/share/bmptiles.c:341–433  ·  view source on GitHub ↗

Read and decode the second header */

Source from the content-addressed store, hash-verified

339
340/* Read and decode the second header */
341static boolean
342read_info_header(FILE *fp, struct BitmapInfoHeader *header)
343{
344 unsigned char buf[124]; /* maximum size */
345 size_t size;
346 boolean have_color_mask;
347
348 memset(header, 0, sizeof(*header));
349
350 /* Get the header size */
351 size = fread(buf, 1, 4, fp);
352 if (size < 4) return FALSE;
353 header->Size = read_u32(buf + 0);
354 if (header->Size > sizeof(buf)) return FALSE;
355
356 /* Get the rest of the header */
357 size = fread(buf + 4, 1, header->Size - 4, fp);
358 if (size < header->Size - 4) return FALSE;
359
360 have_color_mask = FALSE;
361 switch (header->Size) {
362 case 124: /* BITMAPV5INFOHEADER */
363 /* 120 is reserved */
364 header->ProfileSize = read_u32(buf + 116);
365 header->ProfileData = read_u32(buf + 112);
366 header->Intent = read_u32(buf + 108);
367 /* fall through */
368
369 case 108: /* BITMAPV4INFOHEADER */
370 header->GammaBlue = read_u32(buf + 104);
371 header->GammaGreen = read_u32(buf + 100);
372 header->GammaRed = read_u32(buf + 96);
373 header->Endpoints.ciexyzBlue.ciexyzZ = read_u32(buf + 92);
374 header->Endpoints.ciexyzBlue.ciexyzY = read_u32(buf + 88);
375 header->Endpoints.ciexyzBlue.ciexyzX = read_u32(buf + 84);
376 header->Endpoints.ciexyzGreen.ciexyzZ = read_u32(buf + 80);
377 header->Endpoints.ciexyzGreen.ciexyzY = read_u32(buf + 76);
378 header->Endpoints.ciexyzGreen.ciexyzX = read_u32(buf + 72);
379 header->Endpoints.ciexyzRed.ciexyzZ = read_u32(buf + 68);
380 header->Endpoints.ciexyzRed.ciexyzY = read_u32(buf + 64);
381 header->Endpoints.ciexyzRed.ciexyzX = read_u32(buf + 60);
382 header->CSType = read_u32(buf + 56);
383 /* fall through */
384
385 case 56: /* BITMAPV3INFOHEADER */
386 header->AlphaMask = read_u32(buf + 52);
387 /* fall through */
388
389 case 52: /* BITMAPV2INFOHEADER */
390 header->BlueMask = read_u32(buf + 48);
391 header->GreenMask = read_u32(buf + 44);
392 header->RedMask = read_u32(buf + 40);
393 have_color_mask = TRUE;
394 /* fall through */
395
396 case 40: /* BITMAPINFOHEADER */
397 case 64: /* OS22XBITMAPHEADER */
398 /* The last 24 bytes in OS22XBITMAPHEADER are incompatible with the

Callers 1

read_bmp_tilesFunction · 0.85

Calls 4

freadFunction · 0.85
read_s32Function · 0.85
read_u32Function · 0.70
read_u16Function · 0.70

Tested by

no test coverage detected