Skip to main content

Image

Struct Image 

Source
#[non_exhaustive]
pub struct Image { pub width: u32, pub height: u32, pub components: Vec<Component>, pub jp2: Option<Jp2Metadata>, pub report: DecodeReport, }
Expand description

A decoded image: the image area on the reference grid, plus its components.

width and height describe the reference grid image area (Xsiz - XOsiz by Ysiz - YOsiz), which is the coordinate space the components are registered against. Under a resolution reduction of r levels they are that area at the reduced resolution: ceil(Xsiz / 2^r) - ceil(XOsiz / 2^r) by the same in y. A sub-sampled component covers that same area with fewer samples, so its own Component::width/Component::height can be smaller. With unit sub-sampling, the common case, they are equal. A decode of part of the image (a window or a tile in region) has that part as its area, in the same formulas with the part’s bounds for XOsiz..Xsiz and YOsiz..Ysiz.

Components are in output-channel order. For a raw codestream that is SIZ order; a JP2 file’s palette, channel definitions and sRGB option can change the channels (see components). The codestream’s inter-component (color) transform, and a JP2 file’s palette and channel definitions, are part of decoding (unless raw_channels is set); no color conversion is applied unless the caller asks for sRGB output.

The struct is #[non_exhaustive], so fields can be added without a breaking change, and decode is the normal producer. To build one by hand, such as an expected image in a test harness, use Image::new.

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.
§width: u32

The image area’s width: reference-grid points, or points of the reduced grid under a resolution reduction.

§height: u32

The image area’s height, as width.

§components: Vec<Component>

One entry per output channel, or per entry of components when it is set. For a raw codestream, and for a JP2 file with no palette, no channel definitions and as-coded output, that is one per SIZ component, in SIZ order. A palette makes one channel per palette column, channel definitions put the color channels in color order, and sRGB output can change the count (a monochrome profile can give three). Never empty in decoder output.

§jp2: Option<Jp2Metadata>

What the JP2 wrapper said about the samples: their color space and what each channel is. None for a raw codestream.

§report: DecodeReport

What the decode left out. A strict decode (the default) gives the complete report, DecodeReport::default; with strict off it lists what was missing or skipped. Image’s PartialEq compares the report too, so two images with the same samples and different reports are not equal.

Implementations§

Source§

impl Image

Source

pub fn new(width: u32, height: u32, components: Vec<Component>) -> Self

Package components with the reference-grid image area they are registered against, and no JP2 metadata (jp2 is None). The values are stored as given; only decode vouches for their consistency.

Source

pub fn component(&self, index: usize) -> Option<&Component>

The component at index in components order, or None if out of range.

Trait Implementations§

Source§

impl Clone for Image

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 Image

Source§

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

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

impl Eq for Image

Source§

impl PartialEq for Image

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 Image

Auto Trait Implementations§

§

impl Forget for Image

§

impl Freeze for Image

§

impl Move for Image

§

impl RefUnwindSafe for Image

§

impl Send for Image

§

impl Sync for Image

§

impl Unpin for Image

§

impl UnsafeUnpin for Image

§

impl UnwindSafe for Image

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, 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> 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.