MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / checkColorValidity

Function checkColorValidity

external/lodepng/lodepng.cpp:2930–2941  ·  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

2928/*checks if the colortype is valid and the bitdepth bd is allowed for this colortype.
2929Return value is a LodePNG error code.*/
2930static unsigned checkColorValidity(LodePNGColorType colortype, unsigned bd) {
2931 switch(colortype) {
2932 case LCT_GREY: if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8 || bd == 16)) return 37; break;
2933 case LCT_RGB: if(!( bd == 8 || bd == 16)) return 37; break;
2934 case LCT_PALETTE: if(!(bd == 1 || bd == 2 || bd == 4 || bd == 8 )) return 37; break;
2935 case LCT_GREY_ALPHA: if(!( bd == 8 || bd == 16)) return 37; break;
2936 case LCT_RGBA: if(!( bd == 8 || bd == 16)) return 37; break;
2937 case LCT_MAX_OCTET_VALUE: return 31; /* invalid color type */
2938 default: return 31; /* invalid color type */
2939 }
2940 return 0; /*allowed color type / bits combination*/
2941}
2942
2943static unsigned getNumColorChannels(LodePNGColorType colortype) {
2944 switch(colortype) {

Callers 2

lodepng_inspectFunction · 0.85
lodepng_encodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected