//================================================================ int FClamp0255 (int nValue) {return max (0, min (0xFF, nValue));} // 饱和到0--255
class FCObjImage { public : Invert () ; AdjustRGB (int R, int G, int B) ; } ; //================================================================ void FCObjImage::Invert () { if ((GetHandle() == NULL) || (ColorBits() < 24)) return ;
int nSpan = ColorBits() / 8 ; // 每象素字节数3, 4 for (int y=0 ; y < Height() ; y++) { BYTE * pPixel = GetBits (y) ; for (int x=0 ; x < Width() ; x++, pPixel += nSpan) { pPixel[0] = ~pPixel[0] ; pPixel[1] = ~pPixel[1] ; pPixel[2] = ~pPixel[2] ; } } } //================================================================ void FCObjImage::AdjustRGB (int R, int G, int B) { if ((GetHandle() == NULL) || (ColorBits() < 24)) return ;
int nSpan = ColorBits() / 8 ; // 每象素字节数3, 4 for (int y=0 ; y < Height() ; y++) { BYTE * pPixel = GetBits (y) ; for (int x=0 ; x < Width() ; x++, pPixel += nSpan) { pPixel[0] = FClamp0255 (pPixel[0] + B) ; pPixel[1] = FClamp0255 (pPixel[1] + G) ; pPixel[2] = FClamp0255 (pPixel[2] + R) ; } } } //================================================================ |