GSDP:GAM100/CProcessing/imagePixel()
From Inside
< GSDP:GAM100 | CProcessing
imagePixel()
Description
Gets the color of an individual pixel from a PImage. Must have used one of the advanced image functions and set the copyPixelData bool to true.
Parameters
imagePixel(PImage img, float x, float y)
- img - (PImage) The image to check a pixel in
- x - (int) The x coordinate of the pixel in the image.
- y - (int) The y coordinate of the pixel in the image.
Example
PImage justin_face;
PImage tinted_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);
// Tint the image with the color of a random pixel in the image
int x_pixel = randomRangeInt(x_size/2, x_size);
int y_pixel = randomRangeInt(y_size / 2, y_size);
PColor pixel_color = imagePixel(justin_face, x_pixel, y_pixel);
tinted_justin_face = imageCreateTint(justin_face, pixel_color);
}
void update()
{
background(color(255, 255, 255, 255));
image(tinted_justin_face, mouseX, mouseY, 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()