#[non_exhaustive]pub enum ColorSpace {
Srgb,
Grayscale,
Sycc,
RestrictedIcc(Vec<u8>),
Enumerated(u32),
Unknown,
}Expand description
The color space a JP2 file declares for its color channels.
It comes from the first usable Colour Specification (colr) box, the way
OpenJPEG reads it: a box whose method is neither 1 (enumerated) nor 2
(restricted ICC) is skipped and does not count as the first, and every
later usable box is ignored. Boxes placed after jp2h at the top level
count in file order with the ones inside jp2h. This is what the file
declares. Decoding returns the samples as coded unless the caller asks for
ColorOutput::Srgb; then the color channels
are converted and Jp2Metadata::color reports the converted space.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Srgb
sRGB (enumerated color space 16).
Grayscale
Grayscale (enumerated color space 17).
Sycc
sYCC (enumerated color space 18).
RestrictedIcc(Vec<u8>)
A METH 2 box’s ICC profile: the box’s bytes after its three header
bytes, verbatim. The standard restricts it to a monochrome or
three-component matrix/TRC input profile, but that is not checked
here: it holds whatever the box contains.
Applied to the samples only under
ColorOutput::Srgb, which then reports
the converted color space instead. The same bytes are also in that
box’s ColorSpecification::payload on
Jp2Metadata::color_specifications, so the profile is held twice.
Enumerated(u32)
Another enumerated color space value from the first usable box, reported but not interpreted.
Unknown
The file gives no color space: no usable colr box. The image
header’s unknown-color-space flag
(ImageHeader::unknown_color_space) does not change this.