Skip to content

Commit

Permalink
Improve error message in ColorImage::region
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Dec 16, 2024
1 parent 0823a36 commit 450c624
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crates/epaint/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 450c624

Please sign in to comment.