png

Struct Info

source
#[non_exhaustive]
pub struct Info<'a> {
Show 26 fields pub width: u32, pub height: u32, pub bit_depth: BitDepth, pub color_type: ColorType, pub interlaced: bool, pub sbit: Option<Cow<'a, [u8]>>, pub trns: Option<Cow<'a, [u8]>>, pub pixel_dims: Option<PixelDimensions>, pub palette: Option<Cow<'a, [u8]>>, pub gama_chunk: Option<ScaledFloat>, pub chrm_chunk: Option<SourceChromaticities>, pub bkgd: Option<Cow<'a, [u8]>>, pub frame_control: Option<FrameControl>, pub animation_control: Option<AnimationControl>, pub compression: Compression, pub source_gamma: Option<ScaledFloat>, pub source_chromaticities: Option<SourceChromaticities>, pub srgb: Option<SrgbRenderingIntent>, pub icc_profile: Option<Cow<'a, [u8]>>, pub coding_independent_code_points: Option<CodingIndependentCodePoints>, pub mastering_display_color_volume: Option<MasteringDisplayColorVolume>, pub content_light_level: Option<ContentLightLevelInfo>, pub exif_metadata: Option<Cow<'a, [u8]>>, pub uncompressed_latin1_text: Vec<TEXtChunk>, pub compressed_latin1_text: Vec<ZTXtChunk>, pub utf8_text: Vec<ITXtChunk>,
}
Expand description

PNG info struct

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§height: u32§bit_depth: BitDepth§color_type: ColorType

How colors are stored in the image.

§interlaced: bool§sbit: Option<Cow<'a, [u8]>>

The image’s sBIT chunk, if present; contains significant bits of the sample.

§trns: Option<Cow<'a, [u8]>>

The image’s tRNS chunk, if present; contains the alpha channel of the image’s palette, 1 byte per entry.

§pixel_dims: Option<PixelDimensions>§palette: Option<Cow<'a, [u8]>>

The image’s PLTE chunk, if present; contains the RGB channels (in that order) of the image’s palettes, 3 bytes per entry (1 per channel).

§gama_chunk: Option<ScaledFloat>

The contents of the image’s gAMA chunk, if present. Prefer source_gamma to also get the derived replacement gamma from sRGB chunks.

§chrm_chunk: Option<SourceChromaticities>

The contents of the image’s cHRM chunk, if present. Prefer source_chromaticities to also get the derived replacements from sRGB chunks.

§bkgd: Option<Cow<'a, [u8]>>

The contents of the image’s bKGD chunk, if present.

§frame_control: Option<FrameControl>§animation_control: Option<AnimationControl>§compression: Compression§source_gamma: Option<ScaledFloat>

Gamma of the source system. Set by both gAMA as well as to a replacement by sRGB chunk.

§source_chromaticities: Option<SourceChromaticities>

Chromaticities of the source system. Set by both cHRM as well as to a replacement by sRGB chunk.

§srgb: Option<SrgbRenderingIntent>

The rendering intent of an SRGB image.

Presence of this value also indicates that the image conforms to the SRGB color space.

§icc_profile: Option<Cow<'a, [u8]>>

The ICC profile for the image.

§coding_independent_code_points: Option<CodingIndependentCodePoints>

The coding-independent code points for video signal type identification of the image.

§mastering_display_color_volume: Option<MasteringDisplayColorVolume>

The mastering display color volume for the image.

§content_light_level: Option<ContentLightLevelInfo>

The content light information for the image.

§exif_metadata: Option<Cow<'a, [u8]>>

The EXIF metadata for the image.

§uncompressed_latin1_text: Vec<TEXtChunk>

tEXt field

§compressed_latin1_text: Vec<ZTXtChunk>

zTXt field

§utf8_text: Vec<ITXtChunk>

iTXt field

Implementations§

source§

impl Info<'_>

source

pub fn with_size(width: u32, height: u32) -> Self

A utility constructor for a default info with width and height.

source

pub fn size(&self) -> (u32, u32)

Size of the image, width then height.

source

pub fn is_animated(&self) -> bool

Returns true if the image is an APNG image.

source

pub fn animation_control(&self) -> Option<&AnimationControl>

Returns the frame control information of the image.

source

pub fn frame_control(&self) -> Option<&FrameControl>

Returns the frame control information of the current frame

source

pub fn bits_per_pixel(&self) -> usize

Returns the number of bits per pixel.

source

pub fn bytes_per_pixel(&self) -> usize

Returns the number of bytes per pixel.

source

pub fn raw_bytes(&self) -> usize

Returns the number of bytes needed for one deinterlaced image.

source

pub fn raw_row_length(&self) -> usize

Returns the number of bytes needed for one deinterlaced row.

source

pub fn raw_row_length_from_width(&self, width: u32) -> usize

Returns the number of bytes needed for one deinterlaced row of width width.

source

pub fn encode<W: Write>(&self, w: W) -> Result<(), EncodingError>

👎Deprecated: Use Encoder+Writer instead

Encode this header to the writer.

Note that this does not include the PNG signature, it starts with the IHDR chunk and then includes other chunks that were added to the header.

Trait Implementations§

source§

impl<'a> Clone for Info<'a>

source§

fn clone(&self) -> Info<'a>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for Info<'a>

source§

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

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

impl Default for Info<'_>

source§

fn default() -> Info<'static>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Info<'a>

§

impl<'a> RefUnwindSafe for Info<'a>

§

impl<'a> Send for Info<'a>

§

impl<'a> Sync for Info<'a>

§

impl<'a> Unpin for Info<'a>

§

impl<'a> UnwindSafe for Info<'a>

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.