- void bmp::on_openfile_clicked()
- {
- QString ImageFileName = QFileDialog::getOpenFileName(this,"Open Image","e:\\","File(*.jpg *.bmp *.png)");
- if(ImageFileName.isEmpty()) return;
- img.load(ImageFileName);
- pp = pp.fromImage(img).scaledToWidth(ui->label->width());
- ui->label->setPixmap(pp);
- }
- //黑白
- void bmp::on_wb_clicked()
- {
- int w = img.width();
- int h = img.height();
- for(int i=0;i<w;++i){
- for(int j=0;j<h;++j){
- QRgb qr = img.pixel(i,j);
- unsigned int wb = (qRed(qr)+qGreen(qr)+qBlue(qr))/3;
- QRgb v = qRgb(wb,wb,wb);
- img.setPixel(i,j,v);
- }
- }
- pp = pp.fromImage(img).scaledToWidth(ui->label->width());
- ui->label->setPixmap(pp);
- }
- //去除红色
- void bmp::on_RemoveRed_clicked()
- {
- int w = img.width();
- int h = img.height();
- for(int i=0;i<w;++i){
- for(int j=0;j<h;++j){
- QRgb qr = img.pixel(i,j);
- qr = qRgb(0,qGreen(qr),qBlue(qr));
- img.setPixel(i,j,qr);
- }
- }
- pp = pp.fromImage(img).scaledToWidth(ui->label->width());
- ui->label->setPixmap(pp);
- }
typedef QRgb
An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.
The type also holds a value for the alpha-channel. The default alpha channel is ff, i.e opaque. For more information, see the Alpha-Blended Drawing section.