You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TODO note in encode_png to eliminate the clone of the Pixmap can be addressed by adding a variant function that consumes self. Here's an example I've implemented from the outside:
pubfninto_png(mutimage:MaybeFromPool<Pixmap>) -> Result<Vec<u8>, png::EncodingError>{for pixel in image.pixels_mut(){unsafe{// Treat this PremultipliedColorU8 slice as a ColorU8 slice*pixel = mem::transmute(pixel.demultiply());}}letmut data = Vec::with_capacity(1024*1024);{letmut encoder = png::Encoder::new(&mut data, image.width(), image.height());
encoder.set_color(png::ColorType::Rgba);
encoder.set_depth(png::BitDepth::Eight);letmut writer = encoder.write_header()?;
writer.write_image_data(image.data())?;}Ok(data)}
The text was updated successfully, but these errors were encountered:
That's more or less the point: it can be obtained with a method such as Arc::unwrap_or_clone or Cow::into_owned so that the question of whether to keep a copy for future use is separate from tiny-skia's responsibilities.
The TODO note in encode_png to eliminate the clone of the Pixmap can be addressed by adding a variant function that consumes
self
. Here's an example I've implemented from the outside:The text was updated successfully, but these errors were encountered: