add bitmap conversion from aseprite ico, add boot animation
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
@@ -0,0 +1,56 @@
|
||||
use std::fs;
|
||||
use std::process::Command;
|
||||
use std::string::ToString;
|
||||
|
||||
fn main() {
|
||||
for entry in fs::read_dir(".").unwrap() {
|
||||
let entry = entry.unwrap();
|
||||
let path = entry.path();
|
||||
|
||||
if !path.display().to_string().ends_with(".ico") {
|
||||
continue;
|
||||
}
|
||||
|
||||
let name = path.file_stem().unwrap().to_str().unwrap();
|
||||
|
||||
Command::new("/bin/convert").arg(&path).arg("./tmp.xbm").output().unwrap();
|
||||
|
||||
let content = fs::read_to_string("./tmp.xbm").unwrap();
|
||||
|
||||
let a = content.find('{').unwrap() + 1;
|
||||
let b = content.find('}').unwrap();
|
||||
|
||||
let bytes = &content[a..b].trim();
|
||||
|
||||
let bytes = bytes.split(",")
|
||||
.map(|s| s.trim())
|
||||
.filter(|s| !s.is_empty())
|
||||
.map(|s| u8::from_str_radix(&s[2..], 16).unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert!(bytes.len() == 8);
|
||||
|
||||
let mut columns : [u8; 5] = [0,0,0,0,0];
|
||||
|
||||
for (n, r) in bytes.iter().enumerate() {
|
||||
for i in 0..5 {
|
||||
if 0 != *r & (1<<i) {
|
||||
columns[i] |= 1 << n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn testchar(c : char) -> bool {
|
||||
c.is_alphanumeric() || c=='_'
|
||||
}
|
||||
|
||||
let mut name = name.replace(|c:char|!testchar(c), "_");
|
||||
if !name.starts_with(testchar) {
|
||||
name = format!("_{}", name);
|
||||
}
|
||||
|
||||
println!("const uint8_t {}[5] = {{ {} }};", name, columns.iter().map(|c| format!("{:#04x}", !c)).collect::<Vec<_>>().join(", "));
|
||||
}
|
||||
|
||||
let _ = fs::remove_file("./tmp.xbm");
|
||||
}
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |