| 5791 | } |
| 5792 | |
| 5793 | static unsigned isGrayICCProfile(const unsigned char* profile, unsigned size) { |
| 5794 | /* |
| 5795 | It is a gray profile if bytes 16-19 are "GRAY", rgb profile if bytes 16-19 |
| 5796 | are "RGB ". We do not perform any full parsing of the ICC profile here, other |
| 5797 | than check those 4 bytes to grayscale profile. Other than that, validity of |
| 5798 | the profile is not checked. This is needed only because the PNG specification |
| 5799 | requires using a non-gray color model if there is an ICC profile with "RGB " |
| 5800 | (sadly limiting compression opportunities if the input data is grayscale RGB |
| 5801 | data), and requires using a gray color model if it is "GRAY". |
| 5802 | */ |
| 5803 | if(size < 20) return 0; |
| 5804 | return profile[16] == 'G' && profile[17] == 'R' && profile[18] == 'A' && profile[19] == 'Y'; |
| 5805 | } |
| 5806 | |
| 5807 | static unsigned isRGBICCProfile(const unsigned char* profile, unsigned size) { |
| 5808 | /* See comment in isGrayICCProfile*/ |