feat: accept sub-byte bit depths for all color types

Previously, sub-byte bit depths (1-7 bits per sample) were only
accepted for Gray and Multiband color types. This extends the
validation to accept all color types (RGB, RGBA, CMYK, CMYKA, YCbCr)
at sub-byte depths.

The data format is unchanged: sub-byte samples remain packed MSB-first
in the output buffer, exactly as for grayscale. Predictors are still
rejected for sub-byte data.

Tested via libtiffpic flower-rgb-contig-02/04 and flower-rgb-planar-02/04.
This commit is contained in:
Lilith River committed 2026-03-10 06:02:19 -06:00
1 parent 3d3c16e26f
commit 4ff374990e
1 file changed
+6 -1
+6 -1
View File
@@ -1030,7 +1030,12 @@ impl Image {
bit_depth: n, bit_depth: n,
num_samples: _, num_samples: _,
} if n == 8 || n == 16 || n == 32 || n == 64 => {} } if n == 8 || n == 16 || n == 32 || n == 64 => {}
ColorType::Gray(n) ColorType::RGB(n)
| ColorType::RGBA(n)
| ColorType::CMYK(n)
| ColorType::CMYKA(n)
| ColorType::YCbCr(n)
| ColorType::Gray(n)
| ColorType::Palette(n) | ColorType::Palette(n)
| ColorType::Multiband { | ColorType::Multiband {
bit_depth: n, bit_depth: n,