encode

Function encode 

Source
pub fn encode(
    writer: &mut dyn Write,
    image: ImageView<'_>,
    format: Format,
    progress: Option<&mut Progress<'_>>,
    options: &EncodeOptions,
) -> Result<(), EncodingError>
Expand description

Encodes a single surfaces in the given format and writes the encoded pixel data to the given writer.

If an error is returned (or the operation is cancelled), the writer may be in an inconsistent state. Some, all, or none of the pixel data may have been written.

If progress is cancelled before this function returns, EncodingError::Cancelled is returned (unless another error occurs first). Passing None as progress is equivalent to Progress::none().

ยงPanics

Panics if:

  1. writer panics during writes.
  2. The underlying reporter function of progress panics (if given).
  3. An allocation fails.