Struct lodepng::Decoder

source ·
pub struct Decoder { /* private fields */ }
Expand description

Read an image with custom settings

Implementations§

source§

impl Decoder

source

pub fn new() -> Self

source

pub fn info_raw(&self) -> &ColorMode

source

pub fn info_raw_mut(&mut self) -> &mut ColorMode

Preferred color mode for decoding

source

pub fn info_png(&self) -> &Info

Actual color mode of the decoded image or inspected file

source

pub fn info_png_mut(&mut self) -> &mut Info

source

pub fn color_convert(&mut self, true_or_false: bool)

whether to convert the PNG to the color type you want. Default: yes

source

pub fn read_text_chunks(&mut self, true_or_false: bool)

if false but remember_unknown_chunks is true, they’re stored in the unknown chunks.

source

pub fn remember_unknown_chunks(&mut self, true_or_false: bool)

store all bytes from unknown chunks in the Info (off by default, useful for a png editor)

source

pub fn get_icc(&self) -> Result<Vec<u8>, Error>

Decompress ICC profile from iCCP chunk. Only available if remember_unknown_chunks was set.

source

pub fn decode<Bytes: AsRef<[u8]>>( &mut self, input: Bytes ) -> Result<Image, Error>

Load PNG from buffer using Decoder’s settings


state.info_raw_mut().colortype = ColorType::RGBA;
match state.decode(&slice) {
    Ok(Image::RGBA(with_alpha)) => do_stuff(with_alpha),
    _ => panic!("¯\\_(ツ)_/¯")
}
source

pub fn decode_file<P: AsRef<Path>>( &mut self, filepath: P ) -> Result<Image, Error>

Decode a file from disk using Decoder’s settings

source

pub fn inspect(&mut self, input: &[u8]) -> Result<(usize, usize), Error>

Updates info_png. Returns (width, height)

source

pub fn set_custom_zlib( &mut self, callback: custom_decompress_callback, context: *const c_void )

use custom zlib decoder instead of built in one

source

pub fn set_custom_inflate( &mut self, callback: custom_decompress_callback, context: *const c_void )

use custom deflate decoder instead of built in one.

If custom_zlib is used, custom_inflate is ignored since only the built in zlib function will call custom_inflate

Trait Implementations§

source§

impl Clone for Decoder

source§

fn clone(&self) -> Decoder

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 Debug for Decoder

source§

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

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

impl Default for Decoder

source§

fn default() -> Decoder

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

Auto Trait Implementations§

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

§

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

§

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

§

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.