image
image copied to clipboard
Add support for saving 16-bit images to pnm formats
Should hopefully resolve #2430, as well as #1687. It takes the assumption that when an image is 16-bit and the encoder receives a &[u8], it means that the samples were in reality 16-bit and the slice was cast to a byte slice.
Summary
- add sample adaptation layer which recovers 16-bit samples from the original image buffer depending on the color type provided
- Once this is done, the number of samples should match the expected number of samples, and the rest of the encoding process should simply work
- allow for RGB and RGB Alpha tuple types in header check
- add test suite
save_pnm.rsand test sample images from pngsuite:basi0g16.png: 16-bit grayscale imagebasn2c16.png: 16-bit RGB image
Known caveat
- I am not entirely sure whether the assumption can be made in general, or whether it would be possible for someone to request 8-bit samples to be extended and encoded as 16-bit through the encoder.
- While this should also enable the encode to write PAM files, AFAIK PAM file decoding is not yet supported in the library.