From 54684770a41b7f0f303a10262eb8a564b5ddd726 Mon Sep 17 00:00:00 2001 From: ZeWaka Date: Tue, 19 Dec 2023 23:16:45 -0800 Subject: [PATCH] tg """maintainer""" moment --- src/icon.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/icon.rs b/src/icon.rs index 17ad63e..644bf02 100644 --- a/src/icon.rs +++ b/src/icon.rs @@ -2,7 +2,6 @@ use crate::{error, ztxt, RawDmi}; use image::codecs::png; use image::imageops; use image::GenericImageView; -use image::ImageEncoder; use std::collections::HashMap; use std::io::prelude::*; use std::io::Cursor; @@ -357,16 +356,13 @@ impl Icon { } let mut dmi_data = Cursor::new(vec![]); - // We're futzing around with pngs directly here so we can use the best possible compression - let bytes = new_png.as_bytes(); - let (width, height) = new_png.dimensions(); - let color = new_png.color(); + // Use the 'Default' compression - the actual default for the library is 'Fast' let encoder = png::PngEncoder::new_with_quality( &mut dmi_data, png::CompressionType::Default, png::FilterType::Adaptive, ); - encoder.write_image(bytes, width, height, color)?; + new_png.write_with_encoder(encoder)?; let mut new_dmi = RawDmi::load(&dmi_data.into_inner()[..])?; let new_ztxt = ztxt::create_ztxt_chunk(signature.as_bytes())?;