From 909a45db6f7a9ec04e9b45c086a499e5d6f38eb9 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Tue, 24 Oct 2023 17:49:08 +0400 Subject: Use png crate directly instead of image Reduce dependencies a bit. --- src/utils.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/utils.rs') diff --git a/src/utils.rs b/src/utils.rs index 55e6bce7..80f5a0a1 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,5 +1,5 @@ use std::ffi::OsStr; -use std::io; +use std::io::{self, Write}; use std::os::unix::process::CommandExt; use std::path::PathBuf; use std::process::{Command, Stdio}; @@ -89,3 +89,17 @@ pub fn spawn(command: impl AsRef, args: impl IntoIterator Result<(), png::EncodingError> { + let mut encoder = png::Encoder::new(w, width, height); + encoder.set_color(png::ColorType::Rgba); + encoder.set_depth(png::BitDepth::Eight); + + let mut writer = encoder.write_header()?; + writer.write_image_data(pixels) +} -- cgit