pub struct PngEncoder<W>where
W: Write,{
w: W,
compression: CompressionType,
filter: FilterType,
}
Expand description
PNG encoder
Fields§
§w: W
§compression: CompressionType
§filter: FilterType
Implementations§
§impl<W> PngEncoder<W>where
W: Write,
impl<W> PngEncoder<W>where
W: Write,
pub fn new(w: W) -> PngEncoder<W>
pub fn new(w: W) -> PngEncoder<W>
Create a new encoder that writes its output to w
pub fn new_with_quality(
w: W,
compression: CompressionType,
filter: FilterType
) -> PngEncoder<W>
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 of 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.
Trait Implementations§
§impl<W> ImageEncoder for PngEncoder<W>where
W: Write,
impl<W> ImageEncoder for PngEncoder<W>where
W: Write,
§fn write_image(
self,
buf: &[u8],
width: u32,
height: u32,
color_type: ExtendedColorType
) -> Result<(), ImageError>
fn write_image( self, buf: &[u8], width: u32, height: u32, color_type: ExtendedColorType ) -> Result<(), ImageError>
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.
§fn set_icc_profile(
&mut self,
icc_profile: Vec<u8>
) -> Result<(), UnsupportedError>
fn set_icc_profile( &mut self, icc_profile: Vec<u8> ) -> Result<(), UnsupportedError>
Auto Trait Implementations§
impl<W> Freeze for PngEncoder<W>where
W: Freeze,
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> 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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request