checks if the colortype is valid and the bitdepth bd is allowed for this colortype. Return value is a LodePNG error code.*/
| 2928 | /*checks if the colortype is valid and the bitdepth bd is allowed for this colortype. |
| 2929 | Return value is a LodePNG error code.*/ |
| 2930 | static 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 | |
| 2943 | static unsigned getNumColorChannels(LodePNGColorType colortype) { |
| 2944 | switch(colortype) { |
no outgoing calls
no test coverage detected