Code Explanation for createImageData() Method in HTML5 Canvas:
”wikitechyCanvas” is used to declare the id value of the canvas tag.
The getElementById() method is used to draw the element from id.
getContext(): returns an object that provides methods and properties for drawing on the canvas.
Create a variable “ImageData” the value will be set as (200,200) in x,y direction.
The forloop is used to checking the new object pixel values. For every pixel in an ImageData object there are four pieces of information, the RGBA values:
The red color value is set as (0).
The green color value is set as (0)
The blue color value is set as (255)
The alpha channel value is (255; 0 is transparent and 255 is fully visible)
The image will get canvas using putImageData(imgData, 60, 30).
Output for createImageData() Method in HTML5 Canvas:
canvas is used to draw a rectangle an createImageData() method.
Here the output is displayed by blue color rectangle.
The new blank image will display in canvas using the putImageData(imgData, 60, 30).
Browser Support for createImageData() Method in HTML5 Canvas:
Yes
9.0
Yes
Yes
Yes
Tips and Notes
The color/alpha information in the array is manipulated.
The image data can copy on back to the canvas with the putImageData() method.