2020-04-21 18:49:51 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-04-21 18:49:51 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibGfx/Forward.h>
|
|
|
|
|
#include <LibJS/Heap/Handle.h>
|
|
|
|
|
#include <LibWeb/Bindings/Wrappable.h>
|
|
|
|
|
|
2020-07-28 13:20:36 -03:00
|
|
|
namespace Web::HTML {
|
2020-04-21 18:49:51 -03:00
|
|
|
|
|
|
|
|
class ImageData
|
|
|
|
|
: public RefCounted<ImageData>
|
|
|
|
|
, public Bindings::Wrappable {
|
|
|
|
|
public:
|
|
|
|
|
using WrapperType = Bindings::ImageDataWrapper;
|
|
|
|
|
|
|
|
|
|
static RefPtr<ImageData> create_with_size(JS::GlobalObject&, int width, int height);
|
|
|
|
|
|
|
|
|
|
~ImageData();
|
|
|
|
|
|
2020-06-21 10:57:10 -03:00
|
|
|
unsigned width() const;
|
|
|
|
|
unsigned height() const;
|
2020-04-21 18:49:51 -03:00
|
|
|
|
|
|
|
|
Gfx::Bitmap& bitmap() { return m_bitmap; }
|
|
|
|
|
const Gfx::Bitmap& bitmap() const { return m_bitmap; }
|
|
|
|
|
|
|
|
|
|
JS::Uint8ClampedArray* data();
|
|
|
|
|
const JS::Uint8ClampedArray* data() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
explicit ImageData(NonnullRefPtr<Gfx::Bitmap>, JS::Handle<JS::Uint8ClampedArray>);
|
|
|
|
|
|
|
|
|
|
NonnullRefPtr<Gfx::Bitmap> m_bitmap;
|
|
|
|
|
JS::Handle<JS::Uint8ClampedArray> m_data;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|