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

Function check_info_header

win/share/bmptiles.c:436–483  ·  view source on GitHub ↗

Check the second header for consistency and unsupported features */

Source from the content-addressed store, hash-verified

434
435/* Check the second header for consistency and unsupported features */
436static boolean
437check_info_header(const struct BitmapInfoHeader *header)
438{
439 if (header->NumPlanes != 1) return FALSE;
440 switch (header->BitsPerPixel) {
441#if 0 /* TODO */
442 case 0:
443 if (header->Compression != BI_PNG) return FALSE;
444 /* JPEG not supported */
445 break;
446#endif
447
448 case 1:
449 case 24:
450 if (header->Compression != BI_RGB) return FALSE;
451 break;
452
453 case 4:
454 if (header->Compression != BI_RGB
455 && header->Compression != BI_RLE4) return FALSE;
456 break;
457
458 case 8:
459 if (header->Compression != BI_RGB
460 && header->Compression != BI_RLE8) return FALSE;
461 break;
462
463 case 16:
464 case 32:
465 if (header->Compression != BI_RGB
466 && header->Compression != BI_BITFIELDS) return FALSE;
467 /* Any of the color masks could conceivably be zero; the bitmap, though
468 * limited, would still be meaningful */
469 if (header->Compression == BI_BITFIELDS
470 && header->RedMask == 0
471 && header->GreenMask == 0
472 && header->BlueMask == 0) return FALSE;
473 break;
474
475 default:
476 return FALSE;
477 }
478
479 if (header->Height < 0 && header->Compression != BI_RGB
480 && header->Compression != BI_BITFIELDS) return FALSE;
481
482 return TRUE;
483}
484
485/* Return the number of palette entries to read from the file */
486static unsigned

Callers 1

read_bmp_tilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected