Created
July 21, 2022 16:38
-
-
Save fffiloni/e8ed10bdba4f4063639ba8e42ae4983d to your computer and use it in GitHub Desktop.
Convert a blob to a p5 js image
This file contains 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
let img_result; | |
let img_to_download; | |
function blobToGraphics(buffer){ | |
// Create a blob from the buffer response | |
let myBlob = new Blob([buffer], {type: "image/png"}); | |
console.log(myBlob); | |
let uri = URL.createObjectURL(myBlob); | |
img_result = createImg(uri,'','', function(){ | |
img_to_download = loadImage(uri, function(){ | |
console.log('image ready to download: press "S" to download it !"') | |
}) | |
}).hide(); | |
} | |
function draw(){ | |
image(img_result, 0, 0, width, height); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment