Image data fix (#524)

JS: add constructors for ImageData API
This commit is contained in:
Ivan Hetman 2020-10-07 12:21:02 +03:00 committed by GitHub
parent 306c78459c
commit 03c70e3a06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,20 +15,30 @@
*/
package org.teavm.jso.canvas;
import org.teavm.jso.JSBody;
import org.teavm.jso.JSObject;
import org.teavm.jso.JSProperty;
import org.teavm.jso.typedarrays.Uint8ClampedArray;
public interface ImageData extends JSObject {
@JSProperty
int getWidth();
public abstract class ImageData implements JSObject {
private ImageData() {
}
@JSProperty
int getHeight();
public abstract int getWidth();
@JSProperty
Uint8ClampedArray getData();
public abstract int getHeight();
@JSProperty
void setData(Uint8ClampedArray data);
public abstract Uint8ClampedArray getData();
@JSBody(params = { "array", "width" }, script = "return new ImageData(array, width);")
public static native ImageData create(Uint8ClampedArray array, int width);
@JSBody(params = { "width", "height" }, script = "return new ImageData(width, height);")
public static native ImageData create(int width, int height);
@JSBody(params = { "array", "width", "height" }, script = "return new ImageData(array, width, height);")
public static native ImageData create(Uint8ClampedArray array, int width, int height);
}