How to display an Image in Canvas ?

Tagged: ,

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

    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.