imageio: add limited PNM support for reading

see: http://netpbm.sourceforge.net/

Only reads P5 and P6 pnm files for now.

Change-Id: I2332a623f803df67455047f570f1cff9f464480a
This commit is contained in:
Pascal Massimino
2017-01-30 10:52:19 +01:00
parent 84cef16f47
commit dcf9d82a95
10 changed files with 193 additions and 0 deletions

View File

@ -29,6 +29,10 @@ WebPInputFileFormat WebPGuessImageType(const uint8_t* const data,
format = WEBP_TIFF_FORMAT;
} else if (magic1 == 0x52494646 && magic2 == 0x57454250) {
format = WEBP_WEBP_FORMAT;
} else if (((magic1 >> 24) & 0xff) == 'P') {
const int type = (magic1 >> 16) & 0xff;
// we only support 'P5' and 'P6' for now.
if (type >= '5' && type <= '6') format = WEBP_PNM_FORMAT;
}
}
return format;
@ -51,6 +55,7 @@ WebPImageReader WebPGetImageReader(WebPInputFileFormat format) {
case WEBP_JPEG_FORMAT: return ReadJPEG;
case WEBP_TIFF_FORMAT: return ReadTIFF;
case WEBP_WEBP_FORMAT: return ReadWebP;
case WEBP_PNM_FORMAT: return ReadPNM;
default: return FailReader;
}
}