pub struct PngEncoder { /* private fields */ }Expand description
Encodes a PNG stream.
Implementations§
Source§impl PngEncoder
impl PngEncoder
Sourcepub const fn new() -> PngEncoder
pub const fn new() -> PngEncoder
An encoder at the default compression level.
Sourcepub const fn with_level(level: Level) -> PngEncoder
pub const fn with_level(level: Level) -> PngEncoder
An encoder at an explicit DEFLATE level.
Sourcepub fn with_palette(
self,
colours: usize,
dither: f32,
) -> Result<PngEncoder, PixelsError>
pub fn with_palette( self, colours: usize, dither: f32, ) -> Result<PngEncoder, PixelsError>
This encoder writing a palette image of at most colours entries,
diffusing dither (0..=1) of the quantization error.
§Errors
Returns PixelsError::InvalidArgument for colours outside
2..=256 or dither outside 0..=1.
Sourcepub fn from_options(options: &EncodeOptions) -> PngEncoder
pub fn from_options(options: &EncodeOptions) -> PngEncoder
An encoder configured from generic encode options.
EncodeOptions::compression_level is the DEFLATE level. Without
one, EncodeOptions::quality, which cannot trade fidelity for size
in a lossless format, is read as compression effort, mapping 1..=100
onto levels 1..=9.
EncodeOptions::wants_palette selects palette output, of
EncodeOptions::colours entries (256 by default) dithered by
EncodeOptions::dither (1 by default).
Trait Implementations§
Source§impl Debug for PngEncoder
impl Debug for PngEncoder
Source§impl Default for PngEncoder
impl Default for PngEncoder
Source§fn default() -> PngEncoder
fn default() -> PngEncoder
Returns the “default value” for a type. Read more
Source§impl Encoder for PngEncoder
impl Encoder for PngEncoder
Source§fn set_icc_profile(&mut self, profile: Option<&[u8]>) -> Result<(), PixelsError>
fn set_icc_profile(&mut self, profile: Option<&[u8]>) -> Result<(), PixelsError>
Embed
profile as the image’s ICC colour profile, or write none. Read moreSource§fn set_exif(&mut self, exif: Option<&[u8]>) -> Result<(), PixelsError>
fn set_exif(&mut self, exif: Option<&[u8]>) -> Result<(), PixelsError>
Embed
exif (TIFF-structured bytes, as Decoder::exif gives
them) as the image’s EXIF block, or write none. Read moreSource§fn set_density(&mut self, density: Option<Density>) -> Result<(), PixelsError>
fn set_density(&mut self, density: Option<Density>) -> Result<(), PixelsError>
Record
density as the image’s resolution, or write the format’s
default. Read moreSource§fn write_header(
&mut self,
desc: &ImageDescriptor,
sink: &mut dyn Sink,
) -> Result<(), PixelsError>
fn write_header( &mut self, desc: &ImageDescriptor, sink: &mut dyn Sink, ) -> Result<(), PixelsError>
Begin an image, writing any container header. Read more
Auto Trait Implementations§
impl Freeze for PngEncoder
impl RefUnwindSafe for PngEncoder
impl Send for PngEncoder
impl Sync for PngEncoder
impl Unpin for PngEncoder
impl UnsafeUnpin for PngEncoder
impl UnwindSafe for PngEncoder
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