pub struct Encoder { /* private fields */ }
Expand description
Make an image with custom settings
Implementations§
Source§impl Encoder
impl Encoder
pub fn new() -> Self
Sourcepub fn set_palette(&mut self, palette: &[RGBA]) -> Result<(), Error>
pub fn set_palette(&mut self, palette: &[RGBA]) -> Result<(), Error>
Switch color mode to 8-bit palette and set the colors
Sourcepub fn set_auto_convert(&mut self, mode: bool)
pub fn set_auto_convert(&mut self, mode: bool)
If true, convert to output format
Sourcepub fn set_filter_strategy(
&mut self,
mode: FilterStrategy,
palette_filter_zero: bool,
)
pub fn set_filter_strategy( &mut self, mode: FilterStrategy, palette_filter_zero: bool, )
palette_filter_zero
controls filtering for low-bitdepth images
Sourcepub fn set_predefined_filters(&mut self, filters: impl Into<Box<[u8]>>)
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
Sourcepub fn set_text_compression(&mut self, compr: bool)
pub fn set_text_compression(&mut self, compr: bool)
gzip text metadata
Sourcepub fn set_custom_zlib(
&mut self,
callback: custom_compress_callback,
context: *const c_void,
)
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.
Sourcepub fn set_custom_deflate(
&mut self,
callback: custom_compress_callback,
context: *const c_void,
)
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.
pub fn info_raw(&self) -> &ColorMode
Sourcepub fn info_raw_mut(&mut self) -> &mut ColorMode
pub fn info_raw_mut(&mut self) -> &mut ColorMode
Color mode of the source bytes to be encoded
pub fn info_png(&self) -> &Info
Sourcepub fn info_png_mut(&mut self) -> &mut Info
pub fn info_png_mut(&mut self) -> &mut Info
Color mode of the file to be created
Sourcepub fn encode<PixelType: Pod>(
&self,
image: &[PixelType],
w: usize,
h: usize,
) -> Result<Vec<u8>, Error>
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”
Sourcepub fn encode_file<PixelType: Pod, P: AsRef<Path>>(
&self,
filepath: P,
image: &[PixelType],
w: usize,
h: usize,
) -> Result<(), Error>
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”
pub fn settings_mut(&mut self) -> &mut EncoderSettings
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Encoder
impl RefUnwindSafe for Encoder
impl Send for Encoder
impl Sync for Encoder
impl Unpin for Encoder
impl UnwindSafe for Encoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more