void brighten( colorImage img, int red, int grn, int blu ) { int r, c ; pixel pix; for ( r=0; r<img.nrows; r++ ) for ( c=0; c<img.ncols; c++ ) { pix = getColorPixel( img, r, c ) ; if ( pix.red+red > 255 ) pix.red = 255; else if ( pix.red+red < 0 ) pix.red = 0; else pix.red += red; if ( pix.grn+grn > 255 ) pix.grn = 255; else if ( pix.grn+grn < 0 ) pix.grn = 0; else pix.grn += grn; if ( pix.blu+blu > 255 ) pix.blu = 255; else if ( pix.blu+blu < 0 ) pix.blu = 0; else pix.blu += blu; setColorPixel( img, r, c, pix ); } }
Comments: