GSDP:GAM100/CProcessing/createImageAdvanced()

From Inside
Jump to: navigation, search

createImageAdvanced()

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. Using createImageAdvanced() lets you set a few flags that are described below.

Parameters

createImage(unsigned char* data, int w, int h, bool copyPixelData, bool usePixelPerfectFiltering)

  • 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.
  • copyPixelData - (bool) Copies the pixel data of the image so it can be manipulated later
  • usePixelPerfectFiltering - (bool) Turns off bilinear smoothing for images, good for pixel art.

Example

PImage created;
PImage createdTint;

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 = createImageAdvanced(colors, 2, 2, true, true);
  createdTint = imageCreateTintAdvanced(created, color(127, 127, 127, 255), false, true);
}

void update()
{
  background(color(255, 255, 255, 255));

  image(created, (float)canvasWidth / 2.0f - 100, (float)canvasHeight / 2.0f, 100, 100, 255);
  image(createdTint, (float)canvasWidth / 2.0f + 100, (float)canvasHeight / 2.0f, 100, 100, 255);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>