Search processing.org:

Reference for Processing version 1.0.1+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Name

### image()

Examples

    PImage b;
    // Images must be in the "data" directory to load correctly
    b = loadImage("laDefense.jpg");
    image(b, 0, 0);

    PImage b;
    // Images must be in the "data" directory to load correctly
    b = loadImage("laDefense.jpg");
    image(b, 0, 0);
    image(b, 0, 0, width/2, height/2);

Description

Displays images to the screen. The images must be in the sketch's "data" directory to load correctly. Select "Add file..." from the "Sketch" menu to add the image. Processing currently works with GIF, JPEG, and Targa images. The color of an image may be modified with the tint() function and if a GIF has transparency, it will maintain its transparency. The img parameter specifies the image to display and the x and y parameters define the location of the image from its upper-left corner. The image is displayed at its original size unless the width and height parameters specify a different size. The imageMode() function changes the way the parameters work. A call to imageMode(CORNERS) will change the width and height parameters to define the x and y values of the opposite corner of the image.
Starting with release 0124, when using the default (JAVA2D) renderer, smooth() will also improve image quality of resized images.

Syntax

    image(img, x, y)
    image(img, x, y, width, height)

Parameters

img | PImage: the image to display
x | int or float: x-coordinate of the image
y | int or float: y-coordinate of the image
width | int or float: width to display the image
height | int or float: height to display the image

Usage | Web & Application
Related | loadImage() PImage imageMode() tint() background() alpha()

Updated on November 22, 2008 08:39:25pm PST