<p>Hình ảnh sử dụng:</p>
<img id="imgtest" src="https://laptrinhtudau.com/wp-content/uploads/2021/12/avt-cute-e1639056656543.jpg" alt="hình ảnh test" width="220" height="277">
<p>Đưa vào canvas:</p>
<canvas id="testCanvas" width="250" height="300"
style="border:1px solid #d3d3d3;">
Trình duyệt của bạn không hỗ trợ canvas</canvas>
<p><button onclick="myCanvas()">Xác nhận</button></p>
<script>
function myCanvas() {
var c = document.getElementById("testCanvas");
var ctx = c.getContext("2d");
var img = document.getElementById("imgtest");
ctx.drawImage(img,10,10);
}
</script>
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.