MCPcopy Create free account
hub / github.com/DFHack/dfhack / checkColorValidity

Function checkColorValidity

depends/lodepng/lodepng.cpp:2635–2646  ·  view source on GitHub ↗

checks if the colortype is valid and the bitdepth bd is allowed for this colortype. Return value is a LodePNG error code.*/

Source from the content-addressed store, hash-verified

2633/*checks if the colortype is valid and the bitdepth bd is allowed for this colortype.
2634Return value is a LodePNG error code.*/
2635static unsigned checkColorValidity(LodePNGColorType colortype, unsigned bd) {
2636 switch(colortype) {
2637 case LCT_GREY: if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8 || bd == 16)) return 37; break;
2638 case LCT_RGB: if(!( bd == 8 || bd == 16)) return 37; break;
2639 case LCT_PALETTE: if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8 )) return 37; break;
2640 case LCT_GREY_ALPHA: if(!( bd == 8 || bd == 16)) return 37; break;
2641 case LCT_RGBA: if(!( bd == 8 || bd == 16)) return 37; break;
2642 case LCT_MAX_OCTET_VALUE: return 31; /* invalid color type */
2643 default: return 31; /* invalid color type */
2644 }
2645 return 0; /*allowed color type / bits combination*/
2646}
2647
2648static unsigned getNumColorChannels(LodePNGColorType colortype) {
2649 switch(colortype) {

Callers 2

lodepng_inspectFunction · 0.85
lodepng_encodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected