mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:38:11 +00:00
LibGfx: Use ErrorOr<T> for Bitmap::try_create_wrapper()
This commit is contained in:
parent
2116620db8
commit
83d1460ee8
7 changed files with 18 additions and 11 deletions
|
@ -26,10 +26,10 @@ RefPtr<ImageData> ImageData::create_with_size(JS::GlobalObject& global_object, i
|
|||
|
||||
auto data_handle = JS::make_handle(data);
|
||||
|
||||
auto bitmap = Gfx::Bitmap::try_create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::IntSize(width, height), 1, width * sizeof(u32), data->data().data());
|
||||
if (!bitmap)
|
||||
auto bitmap_or_error = Gfx::Bitmap::try_create_wrapper(Gfx::BitmapFormat::RGBA8888, Gfx::IntSize(width, height), 1, width * sizeof(u32), data->data().data());
|
||||
if (bitmap_or_error.is_error())
|
||||
return nullptr;
|
||||
return adopt_ref(*new ImageData(bitmap.release_nonnull(), move(data_handle)));
|
||||
return adopt_ref(*new ImageData(bitmap_or_error.release_value(), move(data_handle)));
|
||||
}
|
||||
|
||||
ImageData::ImageData(NonnullRefPtr<Gfx::Bitmap> bitmap, JS::Handle<JS::Uint8ClampedArray> data)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue