Support one-bit channels

This commit is contained in:
Michael Pfaff 2024-08-09 01:05:50 -04:00
commit 185cf61d1f

View file

@ -544,6 +544,7 @@ impl<W: Write> PngEncoder<W> {
color: ExtendedColorType,
) -> ImageResult<()> {
let (ct, bits) = match color {
ExtendedColorType::L1 => (png::ColorType::Grayscale, png::BitDepth::One),
ExtendedColorType::L8 => (png::ColorType::Grayscale, png::BitDepth::Eight),
ExtendedColorType::L16 => (png::ColorType::Grayscale, png::BitDepth::Sixteen),
ExtendedColorType::La8 => (png::ColorType::GrayscaleAlpha, png::BitDepth::Eight),
@ -623,7 +624,7 @@ impl<W: Write> ImageEncoder for PngEncoder<W> {
// contract of `write_image`.
// TODO: assumes equal channel bit depth.
match color_type {
L8 | La8 | Rgb8 | Rgba8 => {
L1 | L8 | La8 | Rgb8 | Rgba8 => {
// No reodering necessary for u8
self.encode_inner(buf, width, height, color_type)
}