mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-19 18:52:39 +03:00
daed553a06
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
45 lines
962 B
Plaintext
45 lines
962 B
Plaintext
/* HTML canvas ImageData objects
|
|
*
|
|
* Copyright 2020 Daniel Silverstone <dsilvers@netsurf-browser.org>
|
|
*
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
*
|
|
* Released under the terms of the MIT License,
|
|
* http://www.opensource.org/licenses/mit-license
|
|
*/
|
|
|
|
class ImageData {
|
|
private int width;
|
|
private int height;
|
|
private uint8_t *data;
|
|
};
|
|
|
|
init ImageData(int width, int height)
|
|
%{
|
|
priv->width = width;
|
|
priv->height = height;
|
|
priv->data = duk_push_buffer(ctx, width * height * 4, false);
|
|
duk_put_prop_string(ctx, 0, MAGIC(DATA));
|
|
duk_pop(ctx);
|
|
%}
|
|
|
|
getter ImageData::width()
|
|
%{
|
|
duk_push_int(ctx, priv->width);
|
|
return 1;
|
|
%}
|
|
|
|
getter ImageData::height()
|
|
%{
|
|
duk_push_int(ctx, priv->height);
|
|
return 1;
|
|
%}
|
|
|
|
getter ImageData::data()
|
|
%{
|
|
duk_push_this(ctx);
|
|
duk_get_prop_string(ctx, -1, MAGIC(DATA));
|
|
duk_push_buffer_object(ctx, -1, 0, priv->width * priv->height * 4, DUK_BUFOBJ_UINT8CLAMPEDARRAY);
|
|
return 1;
|
|
%}
|