How to display an Image in Canvas ?

Home Forums Web Development HTML5 How to display an Image in Canvas ?

Tagged: ,

This topic contains 1 reply, has 2 voices, and was last updated by  Hirendra Sisodiya 2 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5093

    Ankur
    Moderator

    Hello,

    I want to display my image in HTML5 Canvas.

    Following is my code

    var canvas = document.getElementById(“canvas”);
    var ctx = canvas.getContext(“2d”);
    var img = new Image();

    img.src = “Capture.PNG”;
    ctx.drawImage(img, 500, 500);

    But it’s not working.

    Thanks
    Ankur

    #5147

    You should look into browser’s console and fix the issue if any error is present there related to canvas or img object. Check your image source path.

    Good Luck.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.