Ma taille d'image est de 940 * 300 mais la toile html5 montre seulement une partie de l'image en chrome. Pouvez-vous s'il vous plaît aider à résoudre ce problème?La toile html5 ne montre pas l'image complète
est Ci-dessous le code
<!DOCTYPE html>
<html>
<head>
<style></style>
</head>
<body onload="draw();">
<p>Drag me</p>
<canvas id="paint_area"></canvas>
<script>
function draw() {
var ctx = document.getElementById('paint_area').getContext('2d');
//ctx.fillStyle = '#cc3300';
var img_buffer = document.createElement('img');
img_buffer.src = 'http://www.jobcons.in/homebanner.jpg';
var imgWidth = img_buffer.width;
var imgHeight = img_buffer.height;
ctx.width = imgWidth;
ctx.height = imgHeight;
ctx.drawImage(img_buffer,0,0,imgWidth,imgHeight);
}
</script>
</body>
</html>
Vous devez changer '' ctx.width' à ctx.canvas.width'. – Phrogz
@Phrogz: Vous avez raison. J'ai manqué ça. Merci. – pimvdb