Skip to content

Commit

Permalink
fix ooverflow bug
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrgani committed Jan 9, 2025
1 parent 1a079a0 commit d4f1587
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,10 @@ impl Image {
/// Panics if the given pixel coordinates are not inside the image.
// FIXME: change the argument type to u16
pub fn set_pixel(&mut self, x: u32, y: u32, color: Color) {
let x = x as u16;
let y = y as u16;
assert!(x < self.width);
assert!(y < self.height);
assert!(x < self.width as u32);
assert!(y < self.height as u32);

let width = self.width;
let width = self.width as u32;

self.get_image_data_mut()[(y * width + x) as usize] = color.into();
}
Expand Down

0 comments on commit d4f1587

Please sign in to comment.