Enum png::encoder::ChunkOutput

source ·
enum ChunkOutput<'a, W: Write> {
    Borrowed(&'a mut Writer<W>),
    Owned(Writer<W>),
}

Variants§

§

Borrowed(&'a mut Writer<W>)

§

Owned(Writer<W>)

Methods from Deref<Target = Writer<W>>§

source

pub fn write_chunk( &mut self, name: ChunkType, data: &[u8] ) -> Result<(), EncodingError>

Write a raw chunk of PNG data.

The chunk will have its CRC calculated and correctly. The data is not filtered in any way, but the chunk needs to be short enough to have its length encoded correctly.

source

pub fn write_text_chunk<T: EncodableTextChunk>( &mut self, text_chunk: &T ) -> Result<(), EncodingError>

source

fn validate_new_image(&self) -> Result<(), EncodingError>

Check if we should allow writing another image.

source

fn validate_sequence_done(&self) -> Result<(), EncodingError>

source

const MAX_IDAT_CHUNK_LEN: u32 = 2_147_483_647u32

source

const MAX_fdAT_CHUNK_LEN: u32 = 2_147_483_643u32

source

pub fn write_image_data(&mut self, data: &[u8]) -> Result<(), EncodingError>

Writes the next image data.

source

fn increment_images_written(&mut self)

source

fn write_iend(&mut self) -> Result<(), EncodingError>

source

fn should_skip_frame_control_on_default_image(&self) -> bool

source

fn write_zlib_encoded_idat( &mut self, zlib_encoded: &[u8] ) -> Result<(), EncodingError>

source

pub fn set_filter(&mut self, filter: FilterType)

Set the used filter type for the following frames.

The default filter is FilterType::Sub which provides a basic prediction algorithm for sample values based on the previous. For a potentially better compression ratio, at the cost of more complex processing, try out FilterType::Paeth.

source

pub fn set_adaptive_filter(&mut self, adaptive_filter: AdaptiveFilterType)

Set the adaptive filter type for the following frames.

Adaptive filtering attempts to select the best filter for each line based on heuristics which minimize the file size for compression rather than use a single filter for the entire image. The default method is AdaptiveFilterType::NonAdaptive.

source

pub 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 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.

source

pub 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;

source

pub 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;

source

pub 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_position should be called first.

This method will return an error if the image is not animated.

source

pub 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.

source

pub 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 BlendOp documentation 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.

source

pub 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 DisposeOp documentation for the possible values and their effects.

Note that if the first frame uses DisposeOp::Previous it will be treated as DisposeOp::Background.

This method will return an error if the image is not animated.

source

pub fn stream_writer(&mut self) -> Result<StreamWriter<'_, W>, EncodingError>

Create a stream writer.

This allows you to create images that do not fit in memory. The default chunk size is 4K, use stream_writer_with_size to set another chunk size.

This borrows the writer which allows for manually appending additional chunks after the image data has been written.

source

pub fn stream_writer_with_size( &mut self, size: usize ) -> Result<StreamWriter<'_, W>, EncodingError>

Create a stream writer with custom buffer size.

See stream_writer.

Trait Implementations§

source§

impl<'a, W: Write> Deref for ChunkOutput<'a, W>

§

type Target = Writer<W>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a, W: Write> DerefMut for ChunkOutput<'a, W>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a, W> RefUnwindSafe for ChunkOutput<'a, W>where W: RefUnwindSafe,

§

impl<'a, W> Send for ChunkOutput<'a, W>where W: Send,

§

impl<'a, W> Sync for ChunkOutput<'a, W>where W: Sync,

§

impl<'a, W> Unpin for ChunkOutput<'a, W>where W: Unpin,

§

impl<'a, W> !UnwindSafe for ChunkOutput<'a, W>

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.