From 6b97273fcf0ffc4bfadea4a2a5c7e3fb9315e375 Mon Sep 17 00:00:00 2001 From: Candifloss Date: Sat, 20 Dec 2025 18:53:39 +0530 Subject: [PATCH] Fix clippy warnings in `wallpaper.rs` --- src/wallpaper.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/wallpaper.rs b/src/wallpaper.rs index 175934d..b94f0ab 100644 --- a/src/wallpaper.rs +++ b/src/wallpaper.rs @@ -53,23 +53,25 @@ fn rgba_to_bgra(mut pixels: Vec) -> Vec { /// - Aspect ratio is preserved /// - Excess image is cropped (centered) fn prepare_fill(img: &RgbaImage, screen_width: u32, screen_height: u32) -> PreparedWallpaper { - let img_w = img.width() as f32; - let img_h = img.height() as f32; + let img_w = f64::from(img.width()); + let img_h = f64::from(img.height()); - let screen_w = screen_width as f32; - let screen_h = screen_height as f32; + let screen_w = f64::from(screen_width); + let screen_h = f64::from(screen_height); // Scale so that BOTH dimensions cover the screen let scale = (screen_w / img_w).max(screen_h / img_h); + #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] let scaled_w = (img_w * scale).round() as u32; + #[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] let scaled_h = (img_h * scale).round() as u32; let resized = imageops::resize(img, scaled_w, scaled_h, imageops::FilterType::Lanczos3); // Center the image; negative offsets cause cropping - let offset_x = (screen_width as i32 - scaled_w as i32) / 2; - let offset_y = (screen_height as i32 - scaled_h as i32) / 2; + let offset_x = (screen_width.cast_signed() - scaled_w.cast_signed()) / 2; + let offset_y = (screen_height.cast_signed() - scaled_h.cast_signed()) / 2; let pixels = rgba_to_bgra(resized.into_raw());