• 5680阅读
  • 2回复

How can I change the bright and contrast of one picture about jpeg or bmp or png? [复制链接]

上一主题 下一主题
离线lsosa
 

只看楼主 倒序阅读 楼主  发表于: 2006-04-14
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.
[ 此贴被XChinux在2006-04-14 13:35重新编辑 ]
离线lsosa

只看该作者 1楼 发表于: 2006-04-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 <= 255 ){
               Color.setHsv(H, S, V);
           }
           Rgb = Color.rgb();
           Img.setPixel(i, j, Rgb);
       }
   }
   // fprintf(stderr, "h:%d, s:%d, v:%d\n", H, S, V);
   Src.convertFromImage(Img);
   // perror("error?");
   pBackBuffer->fill(black);
   bitBlt( pBackBuffer, 0, 0, &Src);
   update();
   
   return TRUE;
}
/*******************************************/

this is the function to change the bright and saturation of the picture, but I haven't realize the contrast changing of the picture, anyone can help me?
离线shiroki

只看该作者 2楼 发表于: 2006-04-28
I think contrast has the same meaning with saturation.
--
shiro is White
ki is tree
http://www.cuteqt.com
论坛 http://www.cuteqt.com/bbs
博客 http://www.cuteqt.com/blog
博客镜像: http://sites.cuteqt.com/cuteqt
Linux/Qt/嵌入式讨论群 http://qun.qq.com/air/5699823
快速回复
限100 字节
 
上一个 下一个