Compare commits

..

1 commit

Author SHA1 Message Date
Valentin Weber
7417212c29
Merge 58ea934c9f into 5d745ab8fd 2025-07-19 12:39:42 +02:00
3 changed files with 20 additions and 791 deletions

793
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,7 @@
#![warn(clippy::all, clippy::pedantic)] #![warn(clippy::all, clippy::pedantic)]
#![allow(clippy::unnecessary_debug_formatting)] #![allow(clippy::unnecessary_debug_formatting)]
#![allow(clippy::too_many_lines)]
use std::{fs, io::BufReader, path::PathBuf}; use std::{fs, fs::File, io::BufReader, path::PathBuf};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use base64::Engine; use base64::Engine;
@ -15,11 +14,10 @@ use embedded_graphics::{
text::Text, text::Text,
Drawable, Pixel, Drawable, Pixel,
}; };
use image::{
codecs::gif::GifDecoder, imageops::FilterType, AnimationDecoder, ImageReader,
Pixel as ImagePixel,
};
use serde::Deserialize; use serde::Deserialize;
use image::{
codecs::gif::GifDecoder, imageops::FilterType, AnimationDecoder, ImageReader, Pixel as iPixel,
};
use badgemagic::{ use badgemagic::{
ble::Device as BleDevice, ble::Device as BleDevice,
@ -237,7 +235,7 @@ fn generate_payload(args: &mut Args) -> Result<PayloadBuffer> {
.resize(u32::MAX, 11, FilterType::Nearest) .resize(u32::MAX, 11, FilterType::Nearest)
.into_luma8(); .into_luma8();
let (width, height) = img.dimensions(); let (width, height) = img.dimensions();
let mut buffer = payload.add_message(style, (width as usize).div_ceil(8)); let mut buffer = payload.add_message(style, (width as usize + 7) / 8);
for y in 0..height { for y in 0..height {
for x in 0..width { for x in 0..width {
if img.get_pixel(x, y).0 > [31] { if img.get_pixel(x, y).0 > [31] {
@ -248,7 +246,7 @@ fn generate_payload(args: &mut Args) -> Result<PayloadBuffer> {
} }
} }
Content::GifFile { gif_file } => { Content::GifFile { gif_file } => {
let file_in = BufReader::new(fs::File::open(gif_file)?); let file_in = BufReader::new(File::open(gif_file)?);
let frames = GifDecoder::new(file_in)? let frames = GifDecoder::new(file_in)?
.into_frames() .into_frames()
.collect_frames() .collect_frames()
@ -260,7 +258,7 @@ fn generate_payload(args: &mut Args) -> Result<PayloadBuffer> {
anyhow::bail!("Expected 44x11 pixel gif file"); anyhow::bail!("Expected 44x11 pixel gif file");
} }
let mut buffer = payload.add_message(style, (48 * frame_count).div_ceil(8)); let mut buffer = payload.add_message(style, (48 * frame_count + 7) / 8);
for (i, frame) in frames.iter().enumerate() { for (i, frame) in frames.iter().enumerate() {
let buf = frame.buffer(); let buf = frame.buffer();