Struct StreamWriter
pub struct StreamWriter<'a, W: Write> { /* private fields */ }
Streaming PNG writer
This may silently fail in the destructor, so it is a good idea to call
finish or flush before dropping.
Implementations
impl<'a, W: Write> StreamWriter<'a, W>
fn set_filter(&mut self, filter: Filter)Set the used filter type.
The default filter is
Filter::Adaptivewhich automatically selects the best filter for each row of the image.You should only change this if you are after very fast compression, and either don't care about compression ratio or know exactly what works best for your images.
fn set_frame_delay(&mut self, numerator: u16, denominator: u16) -> Result<(), EncodingError>Set the fraction of time the following frames are going to be displayed, in seconds
If the denominator is 0, it is to be treated as if it were 100 (that is, the numerator then specifies 1/100ths of a second). If the value of the numerator is 0 the decoder should render the next frame as quickly as possible, though viewers may impose a reasonable lower bound.
This method will return an error if the image is not animated.
fn set_frame_dimension(&mut self, width: u32, height: u32) -> Result<(), EncodingError>Set the dimension of the following frames.
This function will return an error when:
-
The image is not an animated;
-
The selected dimension, considering also the current frame position, goes outside the image boundaries;
-
One or both the width and height are 0;
-
fn set_frame_position(&mut self, x: u32, y: u32) -> Result<(), EncodingError>Set the position of the following frames.
An error will be returned if:
-
The image is not animated;
-
The selected position, considering also the current frame dimension, goes outside the image boundaries;
-
fn reset_frame_dimension(&mut self) -> Result<(), EncodingError>Set the frame dimension to occupy all the image, starting from the current position.
To reset the frame to the full image size
reset_frame_positionshould be called first.This method will return an error if the image is not animated.
fn reset_frame_position(&mut self) -> Result<(), EncodingError>Set the frame position to (0, 0).
Equivalent to calling
set_frame_position(0, 0).This method will return an error if the image is not animated.
fn set_blend_op(&mut self, op: BlendOp) -> Result<(), EncodingError>Set the blend operation for the following frames.
The blend operation specifies whether the frame is to be alpha blended into the current output buffer content, or whether it should completely replace its region in the output buffer.
See the
BlendOpdocumentation for the possible values and their effects.Note that for the first frame the two blend modes are functionally equivalent due to the clearing of the output buffer at the beginning of each play.
This method will return an error if the image is not animated.
fn set_dispose_op(&mut self, op: DisposeOp) -> Result<(), EncodingError>Set the dispose operation for the following frames.
The dispose operation specifies how the output buffer should be changed at the end of the delay (before rendering the next frame)
See the
DisposeOpdocumentation for the possible values and their effects.Note that if the first frame uses
DisposeOp::Previousit will be treated asDisposeOp::Background.This method will return an error if the image is not animated.
fn finish(self) -> Result<(), EncodingError>Consume the stream writer with validation.
Unlike a simple drop this ensures that the all data was written correctly. When other validation options (chunk sequencing) had been turned on in the configuration of inner
Writer, then it will also do a check on their correctness. Differently fromWriter::finish, this justflushes, returns error if some data is abandoned.
Trait Implementations
impl<'a, W: Write> Write for StreamWriter<'a, W>
fn write(&mut self, data: &[u8]) -> Result<usize>fn flush(&mut self) -> Result<()>
impl<W: Write> Drop for StreamWriter<'_, W>
fn drop(&mut self)
Auto Trait Implementations
impl<'a, W> !UnwindSafe for StreamWriter<'a, W>
impl<'a, W> Freeze for StreamWriter<'a, W>
where
Wrapper<'a, W>: Freeze,
impl<'a, W> RefUnwindSafe for StreamWriter<'a, W>
where
Wrapper<'a, W>: RefUnwindSafe,
impl<'a, W> Send for StreamWriter<'a, W>
where
Wrapper<'a, W>: Send,
impl<'a, W> Sync for StreamWriter<'a, W>
where
Wrapper<'a, W>: Sync,
impl<'a, W> Unpin for StreamWriter<'a, W>
where
Wrapper<'a, W>: Unpin,
impl<'a, W> UnsafeUnpin for StreamWriter<'a, W>
where
Wrapper<'a, W>: UnsafeUnpin,
Blanket Implementations
impl<T> Any for StreamWriter<'a, W>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for StreamWriter<'a, W>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for StreamWriter<'a, W>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for StreamWriter<'a, W>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for StreamWriter<'a, W>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for StreamWriter<'a, W>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for StreamWriter<'a, W>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>