How can i open an image in a Canvas ? which is encoded
I am using the
var strDataURI = oCanvas.toDataURL();
The output is the encoded base 64 image. How can i draw this image on a canvas?
I want to use the strDataURI and create the Image ? Is it poosible ?
If its not then what possibly can be the solution for loading the image on a canvas ?
Given a data URL, you can create an image (either on the page or purely in JS) by setting the
srcof the image to your data URL. For example:The
drawImage()method of HTML5 Canvas Context lets you copy all or a portion of an image (or canvas, or video) onto a canvas.You might use it like so:
Edit: I previously suggested in this space that it might not be necessary to use the
onloadhandler when a data URI is involved. Based on experimental tests from this question, it is not safe to do so. The above sequence—create the image, set theonloadto use the new image, and then set thesrc—is necessary for some browsers to surely use the results.