Improve error message in ColorImage::region

This commit is contained in:
Emil Ernerfeldt 2024-12-16 15:14:50 +01:00
parent 0823a36952
commit 450c6242e4
1 changed files with 4 additions and 2 deletions

View File

@ -154,8 +154,10 @@ impl ColorImage {
let max_x = (region.max.x * pixels_per_point) as usize;
let min_y = (region.min.y * pixels_per_point) as usize;
let max_y = (region.max.y * pixels_per_point) as usize;
assert!(min_x <= max_x);
assert!(min_y <= max_y);
assert!(
min_x <= max_x && min_y <= max_y,
"Screenshot region is invalid: {region:?}"
);
let width = max_x - min_x;
let height = max_y - min_y;
let mut output = Vec::with_capacity(width * height);