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:
writerpanics during writes.- The underlying reporter function of
progresspanics (if given). - An allocation fails.