html tutorial - imageData Height Property in HTML5 Canvas - html5 - html code - html form

  • The imageData Height is the property of HTML canvas.
  • The property returns the height of an imageData object, in pixels.

Syntax for imageData height property in HTML5 Canvas:


Sample coding for imageData height property in HTML5 Canvas:

Tryit<!DOCTYPE html>
        <title>Wikitechy height property</title>
        <h2>Wikitechy ImageData Height Property</h2>
        <canvas id="Wikitechy Canvas" width="300" height="200" 
                style="border:1px solid blue;">
            var c = document.getElementById("Wikitechy Canvas");
            var context = c.getContext("2d");
            var imgData = context.createImageData(150, 150);
            alert("Height of imgData is: " + imgData.height);
            var img;
            for (img = 0; img <; img += 4) 
      [img+0] = 0;
      [img+1] = 255;
      [img+2] = 0;
      [img+3] = 255;
            context.putImageData(imgData, 20, 20);

Code Explanation for imageData height property in HTML5 Canvas:

imagedata height property in HTML5 canvas Code Explanation

  1. “wikitechyCanvas” is used to define the value id attribute for canvas element.
  2. The getElementById(); method is used to get the element that has the id attributes with the identified value (“wikitechyCanvas”).
  3. The createImageData(); method creates a new, blank ImageData object(150,150).
  4. alert(); method is used to show the alert message.”height of the imgData is:150”.
  5. For();loops through a block of code a number of times.
  6. For every pixel in an ImageData object there are four pieces of information.The color red (from 0-255).so declared the value red is 0. Diclared the value green is 255.
  7. Diclared the value blue is 0. The alpha channel from 0-255; diclared the value is 255.
  8. The putImageData() method puts the image data from a specified imageData object back onto the canvas.(imgData,20,20).

Output for imageData height property in HTML5 Canvas:

imagedata height property in HTML5 canvas Output

  1. The canvas Rectangle with blue border.
  2. Show the output values is fully green 255 and transparent value is fully 255. The imageData height is displayed in the HTML canvas.

Browser Support for imageData height property in HTML5 Canvas:

Yes 9.0 Yes Yes Yes

Related Searches to accept Attribute in html

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add to your ad blocking whitelist or disable your adblocking software.