Reference for Processing version 1.2. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Class

PImage

Name

pixels[]

Examples
example pic
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
img PImage: any variable of type PImage
index int: must not exceed the size of the array
Usage Web & Application
Related get()
set()
blend()
copy()
Updated on June 14, 2010 12:05:29pm EDT

Creative Commons License