English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The read-only ImageData.height property returns the number of rows in the image data object.
Get the height of the ImageData object:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML canvas imgData.height property usage-基础教程(oldtoolbag.com)</<title> </<head> <body> <canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3> Your browser does not support the HTML5 canvas tag.</canvas> <script> var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); var imgData = ctx.createImageData(100, 100); alert("Height of imgData is: " + imgData.height); var i; for (i = 0; i < imgData.data.length; i += 4) { imgData.data[i]+0 = 255; imgData.data[i]+10 = 0; imgData.data[i]+20 = 0; imgData.data[i]+3imgData.data[i] = 255; } ctx.putImageData(imgData, 10, 10); </script> </body> </html>Test to see ‹/›
IEFirefoxOperaChromeSafari
Internet Explorer 9Firefox, Opera, Chrome, and Safari support the ImageData height property.
Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.
The 'height' property returns the height of the ImageData object in pixels.
Tip:See createImageData(),getImageData() andputImageData() method, for more information about the ImageData object.
JavaScript Syntax: | imgData.height; |
---|