fix(timer): add check for zero frequency

This commit is contained in:
2025-11-01 19:18:04 -04:00
parent 3b32f6c3ce
commit 757d10ec65
3 changed files with 13 additions and 7 deletions

View File

@@ -1,7 +1,7 @@
use crate::context::SproutContext;
use crate::utils::framebuffer::Framebuffer;
use crate::utils::read_file_contents;
use anyhow::{Context, Result};
use anyhow::{Context, Result, bail};
use image::imageops::{FilterType, resize};
use image::math::Rect;
use image::{DynamicImage, ImageBuffer, ImageFormat, ImageReader, Rgba};
@@ -118,6 +118,11 @@ fn draw(image: DynamicImage) -> Result<()> {
// Fit the image to the display frame.
let fit = fit_to_frame(&image, display_frame);
// If the image is zero-sized, then we should bail with an error.
if fit.width == 0 || fit.height == 0 {
bail!("calculated frame size is zero");
}
// Resize the image to fit the display frame.
let image = resize_to_fit(&image, fit);