core: Made BitmapData::set_pixel32 use set_pixel32_raw

This commit is contained in:
Nathan Adams 2023-03-19 09:32:42 +01:00
parent 2e487b0661
commit 483afc4f9a
3 changed files with 8 additions and 12 deletions

View File

@ -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

View File

@ -399,8 +399,8 @@ pub fn set_pixel32<'gc>(
args: &[Value<'gc>],
) -> Result<Value<'gc>, 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(

View File

@ -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);
}
}