mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:47:44 +00:00
LibGfx: add Bitmap::clone() method
This commit is contained in:
parent
f470657d57
commit
16ebbde26f
2 changed files with 21 additions and 0 deletions
|
@ -182,6 +182,25 @@ Bitmap::Bitmap(BitmapFormat format, NonnullRefPtr<SharedBuffer>&& shared_buffer,
|
||||||
allocate_palette_from_format(m_format, palette);
|
allocate_palette_from_format(m_format, palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefPtr<Gfx::Bitmap> Bitmap::clone() const
|
||||||
|
{
|
||||||
|
RefPtr<Gfx::Bitmap> new_bitmap {};
|
||||||
|
if (m_purgeable) {
|
||||||
|
new_bitmap = Bitmap::create_purgeable(format(), size());
|
||||||
|
} else {
|
||||||
|
new_bitmap = Bitmap::create(format(), size());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!new_bitmap) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(size_in_bytes() == new_bitmap->size_in_bytes());
|
||||||
|
memcpy(new_bitmap->scanline(0), scanline(0), size_in_bytes());
|
||||||
|
|
||||||
|
return new_bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
RefPtr<Gfx::Bitmap> Bitmap::rotated(Gfx::RotationDirection rotation_direction) const
|
RefPtr<Gfx::Bitmap> Bitmap::rotated(Gfx::RotationDirection rotation_direction) const
|
||||||
{
|
{
|
||||||
auto w = this->width();
|
auto w = this->width();
|
||||||
|
|
|
@ -103,6 +103,8 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefPtr<Gfx::Bitmap> clone() const;
|
||||||
|
|
||||||
RefPtr<Gfx::Bitmap> rotated(Gfx::RotationDirection) const;
|
RefPtr<Gfx::Bitmap> rotated(Gfx::RotationDirection) const;
|
||||||
RefPtr<Gfx::Bitmap> flipped(Gfx::Orientation) const;
|
RefPtr<Gfx::Bitmap> flipped(Gfx::Orientation) const;
|
||||||
RefPtr<Bitmap> to_bitmap_backed_by_shared_buffer() const;
|
RefPtr<Bitmap> to_bitmap_backed_by_shared_buffer() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue