mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:48:14 +00:00
LibWeb: Add ImageData objects and implement 2D context putImageData()
An ImageData is a wrapper around a Bitmap wrapper around a JS::Uint8ClampedArray.
This commit is contained in:
parent
54133c683d
commit
2d4c91df8e
10 changed files with 359 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <LibWeb/DOM/CanvasRenderingContext2D.h>
|
||||
#include <LibWeb/DOM/HTMLCanvasElement.h>
|
||||
#include <LibWeb/DOM/HTMLImageElement.h>
|
||||
#include <LibWeb/DOM/ImageData.h>
|
||||
|
||||
namespace Web {
|
||||
|
||||
|
@ -175,4 +176,18 @@ void CanvasRenderingContext2D::stroke()
|
|||
painter->stroke_path(m_path, m_stroke_style, m_line_width);
|
||||
}
|
||||
|
||||
RefPtr<ImageData> CanvasRenderingContext2D::create_image_data(JS::GlobalObject& global_object, int width, int height) const
|
||||
{
|
||||
return ImageData::create_with_size(global_object, width, height);
|
||||
}
|
||||
|
||||
void CanvasRenderingContext2D::put_image_data(const ImageData& image_data, float x, float y)
|
||||
{
|
||||
auto painter = this->painter();
|
||||
if (!painter)
|
||||
return;
|
||||
|
||||
painter->blit(Gfx::Point(x, y), image_data.bitmap(), image_data.bitmap().rect());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue