Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

But what if library #17

Merged
merged 2 commits into from
Dec 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ exclude = ["src/tests.rs", "tests/*"]

[dependencies]
thiserror = "1.0"
image = { version = "0.24.6", default-features = false, features = ["png"] }
image = { version = "0.24.7", default-features = false, features = ["png"] }
deflate = "1.0"
inflate = "0.4.5"
8 changes: 2 additions & 6 deletions src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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())?;
Expand Down
Loading