Class | PImage | ||||
---|---|---|---|---|---|
Name | pixels[] |
||||
Examples | // @pjs preload must be used to preload the image /* @pjs preload="tower.jpg"; */ PImage img = loadImage("tower.jpg"); int dimension = (img.width*img.height); img.loadPixels(); for (int i=0; i < dimension; i+=2) { img.pixels[i] = color(0, 0, 0); } img.updatePixels(); image(img, 0, 0); |
||||
Description | Array containing the values for all the pixels in the image. These values are of the color datatype. This array is the size of the image, meaning if the image is 100x100 pixels, there will be 10000 values and if the window is 200x300 pixels, there will be 60000 values. The index value defines the position of a value within the array. For example, the statement color b = img.pixels[230] will set the variable b equal to the value at that location in the array. Before accessing this array, the data must loaded with the loadPixels() method. After the array data has been modified, the updatePixels() method must be run to update the changes. Without loadPixels(), running the code may (or will in future releases) result in a NullPointerException. | ||||
Syntax | img.pixels[index] |
||||
Parameters |
|
||||
Usage | Web & Application | ||||
Related | get() set() blend() copy() |