November 2011
Intermediate to advanced
348 pages
7h 2m
English
Now that we know how to access image data, including the RGBA for every pixel in an image or video, our next step is to explore the possibilities of pixel manipulation. In this recipe, we'll invert the colors of an image by inverting the color of each pixel.

WARNING: This recipe must be run on a web server due to security constraints with the getImageData() method.
Follow these steps to invert the colors of an image:
window.onload = function(){
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");image ...Read now
Unlock full access