Name

updatePixels()

Class

PImage

Description

Updates the display window with the data in the pixels[] array. Use in conjunction with loadPixels(). If you're only reading pixels from the array, there's no need to call updatePixels() — updating is only necessary to apply changes.

Examples

  • PImage myImage;
    int halfImage;
    
    void setup() {
      size(400, 400);
      halfImage = width * height/2;
      myImage = loadImage("shells.jpg");
      myImage.loadPixels();
      for (int i = 0; i < halfImage; i++) {
        myImage.pixels[i+halfImage] = myImage.pixels[i];
      }
      myImage.updatePixels();
    }
    
    void draw() {
      image(myImage, 0, 0);
    }
    
    Image output for example 1

Syntax

  • pimg.updatePixels()
  • pimg.updatePixels(x, y, w, h)

Parameters

  • pimg(PImage) any object of type PImage
  • x(int)x-coordinate of the upper-left corner
  • y(int)y-coordinate of the upper-left corner
  • w(int)width
  • h(int)height

Return

  • void