
* Scaling works on native * It works in wasm * Integrate with UI * Remove benchmark * Integrate Hqx into Resizer module * Link against repo for hqx * Remove unused defaultOpts * Re-add test file * Adding size dropdown * Chrome: go and sit on the naughty step * Better docs * Review * Add link to crbug * Update src/codecs/processor-worker/index.ts Co-Authored-By: Jake Archibald <jaffathecake@gmail.com> * Terminate worker inbetween resize jobs
24 lines
1.0 KiB
HTML
24 lines
1.0 KiB
HTML
<!doctype html>
|
|
<script src ="./pkg/squooshhqx.js"></script>
|
|
<script type="module">
|
|
async function run() {
|
|
await wasm_bindgen("./pkg/squooshhqx_bg.wasm");
|
|
const bitmap = await createImageBitmap(await fetch("https://i.imgur.com/MNDnBSc.png").then(r => r.blob()));
|
|
const canvas = document.createElement("canvas");
|
|
canvas.width = bitmap.width;
|
|
canvas.height = bitmap.height;
|
|
const ctx = canvas.getContext("2d");
|
|
ctx.drawImage(bitmap, 0, 0);
|
|
const imgdata = ctx.getImageData(0, 0, bitmap.width, bitmap.height);
|
|
const factor = 4;
|
|
const r = wasm_bindgen.resize(new Uint32Array(imgdata.data.buffer), bitmap.width, bitmap.height, factor);
|
|
|
|
canvas.width = bitmap.width * factor;
|
|
canvas.height = bitmap.height * factor;
|
|
const output = new ImageData(new Uint8ClampedArray(r.buffer), canvas.width, canvas.height);
|
|
ctx.putImageData(output, 0, 0);
|
|
canvas.style = `width: ${canvas.width}px; height: ${canvas.height}px; image-rendering: pixelated;`;
|
|
document.body.append(canvas);
|
|
}
|
|
run();
|
|
</script> |