Interrupts are working again, new fontplate
This commit is contained in:
@@ -34,7 +34,7 @@ fn to_format(img: ImageBuffer<Luma<u8>, Vec<u8>>, width: usize, height: usize) -
|
||||
output
|
||||
}
|
||||
|
||||
fn path_to_image(path: &str) -> (Vec<u8>, String, usize, usize) {
|
||||
fn path_to_image(path: &str) -> (Vec<u8>, usize, usize) {
|
||||
let img = match image::open(path) {
|
||||
Ok(img) => img.to_luma8(),
|
||||
Err(e) => panic!("failed to open image {}: {}", path, e),
|
||||
@@ -45,14 +45,7 @@ fn path_to_image(path: &str) -> (Vec<u8>, String, usize, usize) {
|
||||
|
||||
let bytes = to_format(img, width, height);
|
||||
|
||||
let path = path
|
||||
.split('/')
|
||||
.next_back()
|
||||
.expect("failed to get last part of path");
|
||||
let split: Vec<_> = path.split('.').collect();
|
||||
let name = remove_non_alphanumeric(&split[0..split.len() - 1].join(".")).to_uppercase();
|
||||
|
||||
(bytes, name, width, height)
|
||||
(bytes, width, height)
|
||||
}
|
||||
|
||||
struct ParsedArgs {
|
||||
@@ -69,20 +62,11 @@ impl Parse for ParsedArgs {
|
||||
|
||||
pub fn parse_image(
|
||||
input: TokenStream,
|
||||
) -> Result<
|
||||
(
|
||||
u8,
|
||||
u8,
|
||||
proc_macro2::Ident,
|
||||
usize,
|
||||
Vec<proc_macro2::TokenStream>,
|
||||
),
|
||||
syn::Error,
|
||||
> {
|
||||
) -> Result<(u8, u8, usize, Vec<proc_macro2::TokenStream>), syn::Error> {
|
||||
// parse the input into a comma separated list of arguments
|
||||
let parsed_args = syn::parse::<ParsedArgs>(input)?;
|
||||
// let parsed_args = parse_macro_input!(input as ParsedArgs);
|
||||
let (bytes, name, width, height) = path_to_image(&parsed_args.path);
|
||||
let (bytes, width, height) = path_to_image(&parsed_args.path);
|
||||
|
||||
let width = width as u8;
|
||||
let height = height as u8;
|
||||
@@ -90,14 +74,12 @@ pub fn parse_image(
|
||||
let byte_array = bytes.as_slice();
|
||||
let byte_count = byte_array.len();
|
||||
|
||||
let name_ident = syn::Ident::new(&name, Span::call_site().into());
|
||||
|
||||
let byte_tokens = bytes.iter().map(|b| quote! { #b }).collect::<Vec<_>>();
|
||||
Ok((width, height, name_ident, byte_count, byte_tokens))
|
||||
Ok((width, height, byte_count, byte_tokens))
|
||||
}
|
||||
|
||||
pub fn include_bitmap_image_impl(input: TokenStream) -> TokenStream {
|
||||
let (_, _, _, _, byte_tokens) = parse_image(input).unwrap();
|
||||
let (_, _, _, byte_tokens) = parse_image(input).unwrap();
|
||||
|
||||
let output = quote! {
|
||||
[#(#byte_tokens),*]
|
||||
|
||||
Reference in New Issue
Block a user