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 ?
in javascript , using jquery for canvas id selection :
html5:
Given a data URL, you can create an image (either on the page or purely in JS) by setting the
src
of 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
onload
handler 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 theonload
to use the new image, and then set thesrc
—is necessary for some browsers to surely use the results.Perhaps this fiddle would help ThumbGen - jsFiddle It uses File API and Canvas to dynamically generate thumbnails of images.