diff --git a/core/src/avm1/globals/bitmap_data.rs b/core/src/avm1/globals/bitmap_data.rs index 756855c05..f9b9a4f35 100644 --- a/core/src/avm1/globals/bitmap_data.rs +++ b/core/src/avm1/globals/bitmap_data.rs @@ -226,8 +226,8 @@ pub fn set_pixel32<'gc>( if let (Some(x_val), Some(y_val), Some(color_val)) = (args.get(0), args.get(1), args.get(2)) { - let x = x_val.coerce_to_i32(activation)?; - let y = y_val.coerce_to_i32(activation)?; + let x = x_val.coerce_to_u32(activation)?; + let y = y_val.coerce_to_u32(activation)?; let color = color_val.coerce_to_i32(activation)?; bitmap_data diff --git a/core/src/avm2/globals/flash/display/bitmap_data.rs b/core/src/avm2/globals/flash/display/bitmap_data.rs index fb7122bce..cb3998d6c 100644 --- a/core/src/avm2/globals/flash/display/bitmap_data.rs +++ b/core/src/avm2/globals/flash/display/bitmap_data.rs @@ -399,8 +399,8 @@ pub fn set_pixel32<'gc>( args: &[Value<'gc>], ) -> Result, Error<'gc>> { if let Some(bitmap_data) = this.and_then(|t| t.as_bitmap_data()) { - let x = args.get_i32(activation, 0)?; - let y = args.get_i32(activation, 1)?; + let x = args.get_u32(activation, 0)?; + let y = args.get_u32(activation, 1)?; let color = args.get_i32(activation, 2)?; bitmap_data .write(activation.context.gc_context) @@ -447,7 +447,7 @@ pub fn set_pixels<'gc>( for x in x..x + width { // Copy data from bytearray until EOFError or finished if let Ok(color) = ba_read.read_int_at(ind) { - bitmap_data.set_pixel32(x as i32, y as i32, color.into()); + bitmap_data.set_pixel32(x, y, color.into()); ind += 4; } else { return Err(Error::AvmError(crate::avm2::error::eof_error( diff --git a/core/src/bitmap/bitmap_data.rs b/core/src/bitmap/bitmap_data.rs index 813915de3..1af91db90 100644 --- a/core/src/bitmap/bitmap_data.rs +++ b/core/src/bitmap/bitmap_data.rs @@ -642,13 +642,9 @@ impl<'gc> BitmapData<'gc> { self.pixels[(x + y * self.width) as usize] = color; } - pub fn set_pixel32(&mut self, x: i32, y: i32, color: Color) { - if self.is_point_in_bounds(x, y) { - self.set_pixel32_raw( - x as u32, - y as u32, - color.to_premultiplied_alpha(self.transparency()), - ); + pub fn set_pixel32(&mut self, x: u32, y: u32, color: Color) { + if x < self.width && y < self.height { + self.set_pixel32_raw(x, y, color.to_premultiplied_alpha(self.transparency())); self.set_cpu_dirty(true); } }