GSDP:GAM100/CProcessing/createImage()

From Inside
Jump to: navigation, search

createImage()

Description

Creates a PImage during run-time from a collection of colors values. The number of colors should not be less than Width multiplied with Height.

Parameters

createImage(unsigned char* data, int w, int h)

  • data - (unsigned char *) A pointer to a list of colors in and order like R,G,B,A,R,G,... order
  • w - (int) The desired width of the created image.
  • h - (int) The desired height of the created image.

Example

PImage created;

void init()
{
  unsigned char colors[] = {255,0,0,255,   // Red
                            255,255,0,255, // Yellow
                            0,0,255,255,   // Blue
                            0,255,0,255};  // Green

  created = createImage(colors, 2, 2);
}

void update()
{
  background(color(255, 255, 255, 255));
  image(created, canvasWidth/2, canvasHeight/2, 100, 100, 255);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>