HTML5 : Image on Canvas

Here we will learn about adding image in a canvas.
The concept is to create an Image object, add listener for load event, load the image, on the load complete handler get the image data and draw it on the context of the canvas.

p=new Image();
p.onload=imageLoaded;
imageLoaded=function(evt)
{
var image=evt.target;
context.drawImage(image,100,100);
}
p.src="img/myImage.jpg";

That’s all for an image to be drawn on the Canvas.

Posted from WordPress for Android through my “HTC Wildfire”.

The publish date is taken a day back as to make a post each day.