GSDP:GAM100/CProcessing/imageUpdate()

From Inside
Jump to: navigation, search

imageUpdate()

Description

Saves the changes made to the pixel data of a PImage that was retrieved from imageData(). You must have created the image using one of the advanced image functions and set the copyPixelData bool to be true for this function to work.

Parameters

imageUpdate(PImage img)

  • PImage - (img) The image that is having its' pixel data updated.

Example

PImage justin_face;
int x_size, y_size;

void init()
{
  justin_face = loadImageAdvanced("./Assets/justin1.png", true, false);

  x_size = imageWidth(justin_face);
  y_size = imageHeight(justin_face);

  unsigned char* pixel_data = imageData(justin_face);

  // Go through and invert the color of the image
  unsigned i;
  for (i = 0; i < x_size*y_size*4; ++i)
  {
    if (i % 4 == 3)
      continue;

    pixel_data[i] = (unsigned char)255 - pixel_data[i];
  }

  imageUpdate(justin_face);
}

void update()
{
  background(color(255, 255, 255, 255));
  image(justin_face, canvasWidth/2, canvasHeight/2, x_size, y_size, 255);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>