mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-11 16:26:20 +00:00
Create my own memory
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "rotate",
|
||||
"scripts": {
|
||||
"build": "mv rotate.{as,ts} && asc rotate.ts -b rotate.wasm --validate -O3 && mv rotate.{ts,as}"
|
||||
"build": "mv rotate.{as,ts} && asc rotate.ts -b rotate.wasm --validate -O3 --importMemory && mv rotate.{ts,as}"
|
||||
},
|
||||
"devDependencies": {
|
||||
"assemblyscript": "github:AssemblyScript/assemblyscript"
|
||||
|
||||
Binary file not shown.
@@ -11,8 +11,12 @@ export async function rotate(
|
||||
const numPagesNeeded = Math.ceil(bytesPerImage * 2 / (64 * 1024));
|
||||
const { instance } = (await (WebAssembly as any).instantiateStreaming(
|
||||
fetch(wasmUrl),
|
||||
{
|
||||
env: {
|
||||
memory: new WebAssembly.Memory({ initial: numPagesNeeded }),
|
||||
},
|
||||
},
|
||||
)) as { instance: RotateModuleInstance };
|
||||
instance.exports.memory.grow(numPagesNeeded);
|
||||
|
||||
const view = new Uint8ClampedArray(instance.exports.memory.buffer);
|
||||
view.set(data.data);
|
||||
|
||||
Reference in New Issue
Block a user