through operate bit, like FreeImageImageCodec.
Code: Select all
for (uint i = 0; i < height; ++i)
{
for (uint j = 0; j < width; ++j)
{
uint p = *(((uint*)(rawBuf + i * pitch)) + j);
uint r = (p >> 16) & 0x000000FF;
uint b = (p << 16) & 0x00FF0000;
p &= 0xFF00FF00;
p |= r | b;
// write the adjusted pixel back
*(((uint*)(rawBuf + i * pitch)) + j) = p;
}
}