#[non_exhaustive]pub struct CodedImage {
pub samples: Vec<u8>,
pub codec: Option<Codec>,
pub width: u32,
pub height: u32,
pub components: u8,
pub bits_per_component: u8,
pub color_model: CodecColorModel,
pub icc_profile: Option<Vec<u8>>,
pub embedded_alpha: Option<Vec<u8>>,
pub notes: CodecNotes,
}Expand description
A decoded image as the codec describes it — before any PDF-level interpretation.
Nothing here has had /Decode applied, and nothing here has been
colour-converted beyond the codec’s own mandated transform
(rule R26). That is pdfcer-render’s job.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.samples: Vec<u8>Interleaved samples, row-major, row 0 at the top, packed per
bits_per_component with rows
padded to a byte boundary (§8.9.3) — the same layout the
byte-stream filters produce, so pdfcer-render’s existing
unpacking path is unchanged.
codec: Option<Codec>Which codec produced samples, or None when the chain was
byte-stream filters only. When None, every geometry field
below is an echo of the image dictionary and carries no
independent authority.
width: u32Width in samples as the codestream declares it. May disagree
with /Width; the caller decides which wins and
CodecNotes::geometry_mismatch records the divergence.
height: u32Height in samples as the codestream declares it.
components: u8Components per sample as the codestream declares it. 0 means
“not declared by any codec” (see CodedImage::codec).
bits_per_component: u8Bit depth as the codestream declares it. For DCT this is always
8 (§7.4.8: “each component value shall occupy a byte”, and
Table 89’s “shall always deliver 8-bit samples”). For JPX it
will be authoritative and /BitsPerComponent ignored (Table 89).
color_model: CodecColorModelThe colour model the samples are actually in.
icc_profile: Option<Vec<u8>>An ICC profile carried inside the codestream, if any (JPEG APP2
/ JPX Icc). Reconciled against /ColorSpace by the caller;
never applied here.
embedded_alpha: Option<Vec<u8>>Alpha carried inside the codestream, one 8-bit sample per
pixel in the same row-major order as
samples.
JPX is the only codec that produces this, and /SMaskInData
(Table 89) is what decides whether it is populated: 0 — the
default — means “encoded soft-mask image information shall be
ignored”, so the common case is None even for a codestream
that does carry an opacity channel. 1 fills it in. 2 leaves
it None and sets
CodecNotes::jpx_smask_in_data_preblended, because that value
means the colour channels were preblended with a backdrop and
reconstructing them needs clause 11’s Matte machinery (see
jpx).
The opacity channel is always removed from samples
regardless — it is not a colour component, and leaving it
interleaved would shift every colour one position to the right.
notes: CodecNotesPer-image honesty counters.