loadPixels()
Image / PixelsDescription
Loads the pixel data for the display window into the pixels[] array.
Syntax
void loadPixels()
Parameters
None
Returns
voidRelated
Under the Hood
From Processing.h:
void loadPixels() {}
void loadPixels();
Under the Hood
From Processing.cpp:
void PApplet::loadPixels() {
int total = winWidth * winHeight;
pixels.resize(total);
std::vector<unsigned char> rgba(total * 4);
glReadPixels(0, 0, winWidth, winHeight, GL_RGBA, GL_UNSIGNED_BYTE, rgba.data());
for (int i = 0; i < total; i++) {
unsigned char r = rgba[i*4 + 0];
unsigned char g = rgba[i*4 + 1];
unsigned char b = rgba[i*4 + 2];
unsigned char a = rgba[i*4 + 3];
pixels[i] = (a << 24) | (r << 16) | (g << 8) | b; // ARGB format
}
}