Struct lodepng::Encoder

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

Make an image with custom settings

Implementations§

source§

impl Encoder

source

pub fn new() -> Self

source

pub fn set_palette(&mut self, palette: &[RGBA]) -> Result<(), Error>

Switch color mode to 8-bit palette and set the colors

source

pub fn set_auto_convert(&mut self, mode: bool)

If true, convert to output format

source

pub fn set_filter_strategy( &mut self, mode: FilterStrategy, palette_filter_zero: bool )

palette_filter_zero controls filtering for low-bitdepth images

source

pub fn set_predefined_filters(&mut self, filters: impl Into<Box<[u8]>>)

Filters are 0-5, one per row. https://www.w3.org/TR/PNG-Filters.html

source

pub fn set_text_compression(&mut self, compr: bool)

gzip text metadata

source

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

Compress using another zlib implementation. It’s gzip header + deflate + adler32 checksum.

source

pub fn set_custom_deflate( &mut self, callback: custom_compress_callback, context: *const c_void )

Compress using another deflate implementation. It’s just deflate, without headers or checksum.

source

pub fn info_raw(&self) -> &ColorMode

source

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

Color mode of the source bytes to be encoded

source

pub fn info_png(&self) -> &Info

source

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

Color mode of the file to be created

source

pub fn encode<PixelType: Pod>( &self, image: &[PixelType], w: usize, h: usize ) -> Result<Vec<u8>, Error>

Takes any pixel type, but for safety the type has to be marked as “plain old data”

source

pub fn encode_file<PixelType: Pod, P: AsRef<Path>>( &self, filepath: P, image: &[PixelType], w: usize, h: usize ) -> Result<(), Error>

Takes any pixel type, but for safety the type has to be marked as “plain old data”

source

pub fn settings_mut(&mut self) -> &mut EncoderSettings

Trait Implementations§

source§

impl Clone for Encoder

source§

fn clone(&self) -> Encoder

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 Encoder

source§

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

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

impl Default for Encoder

source§

fn default() -> Encoder

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.