Struct png::Writer

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

PNG writer

Progresses through the image by writing images, frames, or raw individual chunks. This is constructed through Encoder::write_header().

FIXME: Writing of animated chunks might be clearer if we had an adapter that you would call to guarantee the next image to be prefaced with a fcTL-chunk, and all other chunks would be guaranteed to be IDAT/not affected by APNG’s frame control.

Implementations

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.

Writes the next image data.

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.

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.

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.

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;

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;

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.

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.

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.

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.

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.

Create a stream writer with custom buffer size.

See stream_writer.

Turn this into a stream writer for image data.

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.

Turn this into a stream writer with custom buffer size.

See into_stream_writer.

Consume the stream writer with validation.

Unlike a simple drop this ensures that the final chunk was written correctly. When other validation options (chunk sequencing) had been turned on in the configuration then it will also do a check on their correctness before writing the final chunk.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.