, w * h "" RGB -, .
ASCII :
R0 G0 B0 R1 G1 B1 R2 G2 B2 ... R(w-1) G(w-1) B(w-1)
Rn Gn Bn , , n . , "" ; . ( , ,...) - - , .
:
typedef unsigned char byte;
void get_pixel(const byte *image, unsigned int w,
unsigned int x,
unsigned int y,
byte *red, byte *green, byte *blue)
{
const byte * pixel = image + w * y * 3 + 3 * x;
*red = pixel[0];
*green = pixel[1];
*blue = pixel[2];
}
, , . .
, , , , :
unsigned int x, y;
const byte *pixel =
for(y = 0; y < h; ++y)
{
for(x = 0; x < w; ++x, pixel += 3)
{
const byte red = pixel[0], green = pixel[1], blue = pixel[2];
}
}