-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
30 lines (24 loc) · 977 Bytes
/
build.rs
File metadata and controls
30 lines (24 loc) · 977 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use image::{ImageFormat, ImageReader};
use std::io;
use std::path::Path;
fn main() -> io::Result<()> {
// Convert PNG to ICO if it doesn't exist
let icon_path = Path::new("assets/icon.ico");
if !icon_path.exists() {
println!("cargo:warning=Converting ApertureLogo.png to assets/icon.ico");
let img = ImageReader::open("ApertureLogo.png")
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?
.decode()
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
// Resize to 256x256 (max size for ICO format)
let resized = img.resize(256, 256, image::imageops::FilterType::Lanczos3);
resized
.save_with_format(icon_path, ImageFormat::Ico)
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
}
// Compile the Windows resource file with the icon
winres::WindowsResource::new()
.set_icon("assets/icon.ico")
.compile()?;
Ok(())
}