Someone
public text v1 · immutable /** Invert the colors of the image */
void Image::invert(){
// Each channel is written separately
const size_t nPixels = this->_header.width * this->_header.height;
const size_t depth = this->_header.depth;
const size_t nBytes = nPixels * depth;
for( size_t i = 0; i < depth; ++i )
for( size_t j = i; j < nBytes; j += depth ){
this->_pixels[j] = 255 - this->_pixels[j];
}
};