标题:How can I change the bright and contrast of one picture about jpeg or bmp or png?
作者:lsosa
日期:2006-04-14 13:16
内容:
Please see the title:
How can I change the bright and contrast of one picture about jpeg or bmp or png?
I had looked throught all this forum and hadn't anything about this, someone can help me?
Thank you.
#1 [lsosa 04-26 13:26]
I have solved this problem, I will give the sample codes as follows:
/************************************************/
int CMainWindow :: changePicPixel(){
//
QPixmap Src;
QImage Img = NULL;
QColor Color;
QRgb Rgb;
int w, h;
int H, S, V;
int i, j;
Src.load("/root/Desktop/background.jpg");
// pImg = QImage :: fromMimeSource ( QString :: fromAscii ( "/root/Desktop/background.jpg" ) );
Img = Src.convertToImage();
if ( Img == NULL ){ // report error
return FALSE;
}
w = Img.width();
h = Img.height();
for ( i = 0; i < w; i ++ ){
for ( j = 0; j < h; j ++ ){
//
// pRgb = pImg->scanLine(index);
Rgb = Img.pixel( i, j);
Color.setRgb(Rgb);
Color.getHsv(&H, &S, &V);
// fprintf(stderr, "h:%d, s:%d, v:%d", H, S, V);
//H += 30; // hue
S += 30; // 0-255 saturation
//V += 30; // 0-255 brightness
if ( S >= 0 && S
#2 [shiroki 04-28 11:47]
I think contrast has the same meaning with saturation.