pub struct Encoder { /* private fields */ }
Expand description
Make an image with custom settings
Implementations
sourceimpl 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>(
&mut self,
image: &[PixelType],
w: usize,
h: usize
) -> Result<Vec<u8>, Error>
pub fn encode<PixelType: Pod>(
&mut 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>>(
&mut self,
filepath: P,
image: &[PixelType],
w: usize,
h: usize
) -> Result<(), Error>
pub fn encode_file<PixelType: Pod, P: AsRef<Path>>(
&mut 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 RefUnwindSafe for Encoder
impl !Send for Encoder
impl !Sync for Encoder
impl Unpin for Encoder
impl UnwindSafe for Encoder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more