Skip to content

Commit aa565fe

Browse files
authored
But what if library (#17)
1 parent 800054c commit aa565fe

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ exclude = ["src/tests.rs", "tests/*"]
1212

1313
[dependencies]
1414
thiserror = "1.0"
15-
image = { version = "0.24.6", default-features = false, features = ["png"] }
15+
image = { version = "0.24.7", default-features = false, features = ["png"] }
1616
deflate = "1.0"
1717
inflate = "0.4.5"

src/icon.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::{error, ztxt, RawDmi};
22
use image::codecs::png;
33
use image::imageops;
44
use image::GenericImageView;
5-
use image::ImageEncoder;
65
use std::collections::HashMap;
76
use std::io::prelude::*;
87
use std::io::Cursor;
@@ -357,16 +356,13 @@ impl Icon {
357356
}
358357

359358
let mut dmi_data = Cursor::new(vec![]);
360-
// We're futzing around with pngs directly here so we can use the best possible compression
361-
let bytes = new_png.as_bytes();
362-
let (width, height) = new_png.dimensions();
363-
let color = new_png.color();
359+
// Use the 'Default' compression - the actual default for the library is 'Fast'
364360
let encoder = png::PngEncoder::new_with_quality(
365361
&mut dmi_data,
366362
png::CompressionType::Default,
367363
png::FilterType::Adaptive,
368364
);
369-
encoder.write_image(bytes, width, height, color)?;
365+
new_png.write_with_encoder(encoder)?;
370366
let mut new_dmi = RawDmi::load(&dmi_data.into_inner()[..])?;
371367

372368
let new_ztxt = ztxt::create_ztxt_chunk(signature.as_bytes())?;

0 commit comments

Comments
 (0)