Class Name
PImage
Description
Datatype for storing images. Processing can display .gif, .jpg,
.tga, and .png images. Images may be displayed in 2D and 3D
space. Before an image is used, it must be loaded with the loadImage()
function. The PImage class contains fields for the width and
height of the image, as well as an array called pixels[] that
contains the values for every pixel in the image. The methods described below
allow easy access to the image's pixels and alpha channel and simplify the
process of compositing.
Before using the pixels[] array, be sure to use the
loadPixels() method on the image to make sure that the pixel data is
properly loaded.
To create a new image, use the createImage() function. Do not use the
syntax new PImage().
Examples
PImage photo; void setup() { size(400, 400); photo = loadImage("Toyokawa-city.jpg"); } void draw() { image(photo, 0, 0); }
Constructors
PImage(width, height, format, factor)
PImage(width, height, pixels, requiresCheckAlpha, parent)
PImage(width, height, pixels, requiresCheckAlpha, parent, format, factor)
PImage(img)
Fields
Methods
loadPixels()
Loads the pixel data for the image into its pixels[] arrayupdatePixels()
Updates the image with the data in its pixels[] arrayresize()
Resize the image to a new width and heightget()
Reads the color of any pixel or grabs a rectangle of pixelsset()
Writes a color to any pixel or writes an image into anothermask()
Masks part of an image with another image as an alpha channelfilter()
Converts the image to grayscale or black and whitecopy()
Copies the entire imageblendColor()
Blends two color values together based on the blending mode given as the MODE parameterblend()
Copies a pixel or rectangle of pixels using different blending modessave()
Saves the image to a TIFF, TARGA, PNG, or JPEG file
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.