forked from LedgerHQ/app-boilerplate-rust
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.rs
More file actions
34 lines (29 loc) · 1.07 KB
/
build.rs
File metadata and controls
34 lines (29 loc) · 1.07 KB
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
31
32
33
34
use image::{ImageFormat, ImageReader, Pixel};
fn main() {
println!("cargo:rerun-if-changed=script.ld");
println!("cargo:rerun-if-changed=icons/nanox_app_zcash.gif");
println!("cargo:rerun-if-changed=icons/mask_14x14.gif");
let path = std::path::PathBuf::from("icons");
let reader = ImageReader::open(path.join("nanox_app_zcash.gif")).unwrap();
let img = reader.decode().unwrap();
let mut gray = img.into_luma8();
// Apply mask
let mask = ImageReader::open(path.join("mask_14x14.gif"))
.unwrap()
.decode()
.unwrap()
.into_luma8();
for (x, y, mask_pixel) in mask.enumerate_pixels() {
let mask_value = mask_pixel[0];
let mut gray_pixel = *gray.get_pixel(x, y);
if mask_value == 0 {
gray_pixel = image::Luma([0]);
} else {
gray_pixel.invert();
}
gray.put_pixel(x, y, gray_pixel);
}
let glyph_path = std::path::PathBuf::from("glyphs");
gray.save_with_format(glyph_path.join("home_nano_nbgl.png"), ImageFormat::Png)
.unwrap();
}