Add support for PNG decoding (encoding still buggy)

This commit is contained in:
Surma
2020-09-16 23:59:06 +01:00
parent ef920ac6ba
commit 273b4211c9
15 changed files with 718 additions and 4 deletions

View File

@@ -1,6 +1,11 @@
export default class ImageData {
constructor(data, width, height) {
this.data = data;
// Need to manually copy the memory as wasm-bindgen does not by default
// and by the time we get control in JS land, the memory has already
// been corrupted.
// FIXME: This is bad because its overhead that we should only need
// to pay for Rust, not for C++.
this.data = new Uint8ClampedArray(data);
this.width = width;
this.height = height;
}