Created
July 23, 2020 07:46
-
-
Save av01d/5c56122bfae58ba52fb19ec154585767 to your computer and use it in GitHub Desktop.
File to Bitmap (on canvas)
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
/* HTML: | |
<input type="file" id="filepicker"> | |
<canvas id="outCanvas"></canvas> | |
*/ | |
filepicker.addEventListener("change", () => { | |
createImageBitmap(filepicker.files[0]) | |
.then(response => { | |
outCanvas.width = response.width; | |
outCanvas.height = response.height; | |
const ctx = outCanvas.getContext("2d"); | |
ctx.drawImage(response, 0, 0); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment