Difference between revisions of "GSDP:GAM100/CProcessing/imageData()"
From Inside
< GSDP:GAM100 | CProcessing
>Zachary.logsdon |
>Zachary.logsdon |
||
Line 2: | Line 2: | ||
= imageData() = | = imageData() = | ||
== Description == | == Description == | ||
− | Returns the pixel data array of a [[GSDP:GAM100/CProcessing/PImage |PImage]] if it was created | + | Returns the pixel data array of a [[GSDP:GAM100/CProcessing/PImage |PImage]] if it was created using one of the advanced image functions and set the copyPixelData bool to be true. |
==== Parameters ==== | ==== Parameters ==== | ||
Line 16: | Line 16: | ||
void init() | void init() | ||
{ | { | ||
− | + | justin_face = loadImageAdvanced("./Assets/justin1.png", true, false); | |
− | justin_face = | ||
x_size = imageWidth(justin_face); | x_size = imageWidth(justin_face); |
Latest revision as of 16:39, 5 October 2019
imageData()
Description
Returns the pixel data array of a PImage if it was created using one of the advanced image functions and set the copyPixelData bool to be true.
Parameters
imageCreateTint(PImage img)
- img - (PImage) The image to extract the pixel data from.
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
- Main Page
- loadImage()
- loadImageAdvanced()
- image()
- imageRotated()
- imageSize()
- imageMode()
- createImage()
- createImageAdvanced()
- freeImage()
- imageWidth()
- imageHeight()
- imagePixel()
- imageCreateSubimage()
- imageCreateSubimageAdvanced()
- imageCreateTint()
- imageCreateTintAdvanced()
- imageData()
- imageUpdate()
- readFrameBuffer()
- readFrameBufferAdvanced()