mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
LibGfx: Use ErrorOr<T> for Bitmap::clone()
This commit is contained in:
parent
c417820bff
commit
2da4cfcc80
6 changed files with 23 additions and 11 deletions
|
@ -332,17 +332,19 @@ Bitmap::Bitmap(BitmapFormat format, Core::AnonymousBuffer buffer, const IntSize&
|
|||
allocate_palette_from_format(m_format, palette);
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Bitmap> Bitmap::clone() const
|
||||
ErrorOr<NonnullRefPtr<Gfx::Bitmap>> Bitmap::clone() const
|
||||
{
|
||||
auto new_bitmap = Bitmap::try_create(format(), size(), scale());
|
||||
|
||||
if (!new_bitmap)
|
||||
return nullptr;
|
||||
if (!new_bitmap) {
|
||||
// FIXME: Propagate the *real* error, once we have it.
|
||||
return Error::from_errno(ENOMEM);
|
||||
}
|
||||
|
||||
VERIFY(size_in_bytes() == new_bitmap->size_in_bytes());
|
||||
memcpy(new_bitmap->scanline(0), scanline(0), size_in_bytes());
|
||||
|
||||
return new_bitmap;
|
||||
return new_bitmap.release_nonnull();
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Bitmap> Bitmap::rotated(Gfx::RotationDirection rotation_direction) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue