javascript - How to replace image pixel in Webos Palm js -
I want to change the image pixel color with the other colors in the web, so anybody can suggest how I do this . Thanks
This can be done using the HTML5 canvas API. Make the size of a canvas image, and then drag the image to the canvas. Get image data, and stay away!
var canvas = document. GetElementById (canvas); Var reference = canvas.getContext ('2d'); Var image = context.getImageData (0,0, canvas wide, canvas.height); image is now a imageData object, which has an array data , in which all pixels Image included Suppose you want to remove the green column on the sixth column and the third line on the pixel. var index = (5 * image.width + 2) * 4; // six columns of pixels, and two for the third line. // four times, because the four channels are Image.data [index + 1] = 0; // plus one, because we want the second component Once your pixels are manipulated, load the image data back in the canvas.
context.putImageData (image);
Comments
Post a Comment