GSDP:GAM100/CProcessing/imageCreateSubimage()

From Inside
Jump to: navigation, search

imageCreateSubimage()

Description

Returns a PImage that is a copied section of a another PImage. Must have used one of the advanced image functions and set the copyPixelData bool to true.

Parameters

imageCreateSubimage(PImage srcImg, float x, float y, float w, float h)

  • img - (PImage) The source image to copy of section of.
  • x - (int) The x coordinate of which pixel to start the sub-image from.
  • y - (int) The y coordinate of which pixel to start the sub-image from.
  • w - (int) The width of the sub-image in pixels
  • h - (int) The height of the sub-image in pixels

Example

PImage justin_face;
PImage sub_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);
  sub_justin_face = imageCreateSubimage(justin_face, 0, 0, x_size, y_size / 2);
}

void update()
{
  background(color(255, 255, 255, 255));
  image(sub_justin_face, mouseX, mouseY, x_size, y_size/2, 255);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>