HTML canvas ImageData height Property
The ImageData height property is used to return the height of an ImageData object, in pixels.
Syntax:
imgData.height;
Example: In this example, we are using the above-explained property.
html
<!DOCTYPE html>
< html >
< body >
< h3 style = "color:green" >GeeksforGeeks</ h3 >
< h3 >HTML canvas ImageData height property</ h3 >
< canvas id = "myCanvas"
width = "200"
height = "200"
style = "border:2px solid ;" >
</ canvas >
< p id = g eeks></ p >
< script >
let can = document.getElementById("myCanvas");
let gfg = can.getContext("2d");
let imgData = gfg.createImageData(150, 100);
let i;
for (i = 0; i < imgData.data.length ; i += 3) {
imgData.data[i + 0] = 100;
imgData.data[i + 1] = 0;
imgData.data[i + 2] = 0;
}
gfg.putImageData(imgData, 10, 10);
document.getElementById("geeks") .innerHTML =
"Height of imgData is: " + imgData.height
</script>
</ body >
</ html >
|
Output:
Browsers supported:
- Chrome
- Internet Explorer 9.0
- Safari
- Firefox
- Opera
Last Updated :
19 Jun, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...