Skip to main content

CodedImage

Struct CodedImage 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional 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: u32

Width in samples as the codestream declares it. May disagree with /Width; the caller decides which wins and CodecNotes::geometry_mismatch records the divergence.

§height: u32

Height in samples as the codestream declares it.

§components: u8

Components per sample as the codestream declares it. 0 means “not declared by any codec” (see CodedImage::codec).

§bits_per_component: u8

Bit 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: CodecColorModel

The 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: CodecNotes

Per-image honesty counters.

Trait Implementations§

Source§

impl Clone for CodedImage

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CodedImage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CodedImage

Source§

impl PartialEq for CodedImage

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CodedImage

Auto Trait Implementations§

§

impl Forget for CodedImage

§

impl Freeze for CodedImage
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for CodedImage

§

impl RefUnwindSafe for CodedImage

§

impl Send for CodedImage
where RawVecInner: Send,

§

impl Sync for CodedImage
where RawVecInner: Sync,

§

impl Unpin for CodedImage
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for CodedImage

§

impl UnwindSafe for CodedImage
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more