mirror of
https://github.com/edera-dev/sprout.git
synced 2025-12-19 18:40:18 +00:00
fix(splash): check for zero-sized images
This commit is contained in:
@@ -52,6 +52,11 @@ fn fit_to_frame(image: &DynamicImage, frame: Rect) -> Rect {
|
||||
height: image.height(),
|
||||
};
|
||||
|
||||
// Handle the case where the image is zero-sized.
|
||||
if input.height == 0 || input.width == 0 {
|
||||
return input;
|
||||
}
|
||||
|
||||
// Calculate the ratio of the image dimensions.
|
||||
let input_ratio = input.width as f32 / input.height as f32;
|
||||
|
||||
@@ -66,6 +71,11 @@ fn fit_to_frame(image: &DynamicImage, frame: Rect) -> Rect {
|
||||
height: frame.height,
|
||||
};
|
||||
|
||||
// Handle the case where the output is zero-sized.
|
||||
if output.height == 0 || output.width == 0 {
|
||||
return output;
|
||||
}
|
||||
|
||||
if input_ratio < frame_ratio {
|
||||
output.width = (frame.height as f32 * input_ratio).floor() as u32;
|
||||
output.height = frame.height;
|
||||
|
||||
Reference in New Issue
Block a user