Last active
September 23, 2022 20:40
-
-
Save Zyzle/1cf16675d7224ef90b0ef1639c7783a9 to your computer and use it in GitHub Desktop.
Correcting image-colours to work with browsers that don't support 2d context in OffscreenCanvas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Around line 127 | |
createImageBitmap(file).then((ibm) => { | |
let ctx; | |
if (typeof OffscreenCanvasRenderingContext === "function"){ | |
const canvas = new OffscreenCanvas(ibm.width, ibm.height); | |
ctx = canvas.getContext("2d"); | |
} | |
else { | |
const canvas = document.createElement("canvas"); | |
ctx = canvas.getContext("2d"); | |
ctx.canvas.height = ibm.height; | |
ctx.canvas.width = ibm.width; | |
} | |
ctx.drawImage(ibm, 0, 0); | |
// rest of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment