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