HTML Canvas Image Load Embedded

Description

HTML Canvas Image Load Embedded

View in separate window

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Embed Image</title>
    <style>
      #picture {//from  w  ww  .j  a va  2  s. c o  m
        display: none;
      }
    </style>
  </head>
  <body>
    <canvas id="canvas" width="400" height="400"></canvas>
    <img id="picture" src="image1.png">
    
    <script>
    window.onload = function () {
      var canvas = document.getElementById('canvas'),
          context = canvas.getContext('2d'),
          image = document.getElementById('picture');

      context.drawImage(image, 0, 0);
    };
    </script>
  </body>
</html>



PreviousNext

Related