Code
Execute
<!DOCTYPE html> <html> <head> <title>Wikitechy width property</title> </head> <body> <h2>Wikitechy ImageData Width Property</h2> <canvas id="WikitechyCanvas" width="300" height="200" style="border:1px solid blue;"> </canvas> <script> var c = document.getElementById("WikitechyCanvas"); var context = c.getContext("2d"); var imgData = context.createImageData(150, 150); alert("Width of imgData is:"+imgData.width); var img; for (img = 0; img < imgData.data.length; img += 4) { imgData.data[img+0] = 255; imgData.data[img+1] = 0; imgData.data[img+2] = 0; imgData.data[img+3] = 120; } context.putImageData(imgData, 25, 25); </script> </body> </html>
Result