Struct image::codecs::png::PngEncoder

source ·
pub struct PngEncoder<W: Write> { /* private fields */ }
Expand description

PNG encoder

Implementations§

source§

impl<W: Write> PngEncoder<W>

source

pub fn new(w: W) -> PngEncoder<W>

Create a new encoder that writes its output to w

source

pub fn new_with_quality( w: W, compression: CompressionType, filter: FilterType ) -> PngEncoder<W>

Create a new encoder that writes its output to w with CompressionType compression and FilterType filter.

It is best to view the options as a hint to the implementation on the smallest or fastest option for encoding a particular image. That is, using options that map directly to a PNG image parameter will use this parameter where possible. But variants that have no direct mapping may be interpreted differently in minor versions. The exact output is expressly not part the SemVer stability guarantee.

Note that it is not optimal to use a single filter type, so an adaptive filter type is selected as the default. The filter which best minimizes file size may change with the type of compression used.

source

pub fn encode( self, data: &[u8], width: u32, height: u32, color: ColorType ) -> ImageResult<()>

👎Deprecated: Use PngEncoder::write_image instead. Beware that write_image has a different endianness convention

Encodes the image data that has dimensions width and height and ColorType c.

Expects data in big endian.

Trait Implementations§

source§

impl<W: Write> ImageEncoder for PngEncoder<W>

source§

fn write_image( self, buf: &[u8], width: u32, height: u32, color_type: ColorType ) -> ImageResult<()>

Write a PNG image with the specified width, height, and color type.

For color types with 16-bit per channel or larger, the contents of buf should be in native endian. PngEncoder will automatically convert to big endian as required by the underlying PNG format.

Auto Trait Implementations§

§

impl<W> RefUnwindSafe for PngEncoder<W>where W: RefUnwindSafe,

§

impl<W> Send for PngEncoder<W>where W: Send,

§

impl<W> Sync for PngEncoder<W>where W: Sync,

§

impl<W> Unpin for PngEncoder<W>where W: Unpin,

§

impl<W> UnwindSafe for PngEncoder<W>where W: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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, U> TryFrom<U> for Twhere 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 Twhere 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.