mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 15:10:19 +00:00
LibGfx: Add a method to copy a Bitmap to a PaintingSurface
This commit is contained in:
parent
3d8ab0e67c
commit
b08f12d3e6
Notes:
github-actions[bot]
2024-11-13 13:39:39 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/b08f12d3e69 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2309
2 changed files with 10 additions and 0 deletions
|
@ -101,6 +101,15 @@ void PaintingSurface::read_into_bitmap(Gfx::Bitmap& bitmap)
|
|||
m_impl->surface->readPixels(pixmap, 0, 0);
|
||||
}
|
||||
|
||||
void PaintingSurface::write_from_bitmap(Gfx::Bitmap& bitmap)
|
||||
{
|
||||
auto color_type = to_skia_color_type(bitmap.format());
|
||||
auto alpha_type = bitmap.alpha_type() == Gfx::AlphaType::Premultiplied ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
|
||||
auto image_info = SkImageInfo::Make(bitmap.width(), bitmap.height(), color_type, alpha_type);
|
||||
SkPixmap const pixmap(image_info, bitmap.begin(), bitmap.pitch());
|
||||
m_impl->surface->writePixels(pixmap, 0, 0);
|
||||
}
|
||||
|
||||
IntSize PaintingSurface::size() const
|
||||
{
|
||||
return m_impl->size;
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
#endif
|
||||
|
||||
void read_into_bitmap(Bitmap&);
|
||||
void write_from_bitmap(Bitmap&);
|
||||
|
||||
IntSize size() const;
|
||||
IntRect rect() const;
|
||||
|
|
Loading…
Reference in a new issue