Skip to content

Commit

Permalink
LibWeb: Fix new ImageData(width, height) when width != height
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Apr 15, 2024
1 parent 026860c commit fc7ced5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions Tests/LibWeb/Text/input/HTML/ImageData-create-with-size.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
println(imageData.data);
println(imageData.data.length);

imageData = new ImageData(1, 2);
println(imageData.data);
println(imageData.data.length);

const arr = new Uint8ClampedArray(40_000);
// Fill the array with the same RGBA values
for (let i = 0; i < arr.length; i += 4) {
Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/ImageData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ImageData>> ImageData::create(JS::Realm& re
return WebIDL::IndexSizeError::create(realm, "Source height must be equal to the calculated height of the data."_fly_string);

// 7. Initialize this given sw, sh, settings set to settings, and source set to data.
auto bitmap = TRY_OR_THROW_OOM(vm, Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::IntSize(sw, sw), 1, sw * sizeof(u32), uint8_clamped_array_data.data().data()));
auto bitmap = TRY_OR_THROW_OOM(vm, Gfx::Bitmap::create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::IntSize(sw, height), 1, sw * sizeof(u32), uint8_clamped_array_data.data().data()));

return realm.heap().allocate<ImageData>(realm, realm, bitmap, uint8_clamped_array_data);
}
Expand Down

0 comments on commit fc7ced5

Please sign in to comment.