All pastes #242128 Raw Edit

Someone

public text v1 · immutable
·published 2006-11-06 22:54 UTC
rendered paste body
    /** 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];
         }
    };