代码示例:(标识:eg_html5_canvas_image)
<!DOCTYPE html>
<html>
<body>

<p>把一幅图像放置到画布上:</p>

<img id="scream" width="224" height="162"
src="/static/demo/images/eg_flower.png" alt="The Scream">

<p>Canvas:</p>

<canvas id="myCanvas" width="244" height="182"
style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.
</canvas>

<script>
window.onload = function() {
    var canvas = document.getElementById("myCanvas");
    var ctx = canvas.getContext("2d");
    var img = document.getElementById("scream");
   ctx.drawImage(img, 10, 10);
};
</script>

</body>
</html>
运行结果: