Skip to content

Instantly share code, notes, and snippets.

@guest271314
Created November 25, 2019 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guest271314/db0bf90e4c9773bdcda9a3c92ba148c6 to your computer and use it in GitHub Desktop.
Save guest271314/db0bf90e4c9773bdcda9a3c92ba148c6 to your computer and use it in GitHub Desktop.
Convert OffscreenCanvas to ImageData using png.js (OffscreenCanvasRenderingContext2D not implemented at Firefox 70 or Nightly 72)
const imageData = new ImageData(
new Uint8ClampedArray(
new PNG(new Uint8Array(await (await offscreen.toBlob({type: "image/png"})).arrayBuffer())).decodePixels()
)
, offscreen.width, offscreen.height);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment