阅读背景:

Qt修改图片的背景色及设置背景色为透明的方法

来源:互联网 

先上干货。

Qt下修改图片背景色的方法:

方法一:

QPixmap CKnitWidget::ChangeImageColor(QPixmap sourcePixmap, QColor origColor, QColor destColor)
{
    QImage image = sourcePixmap.toImage();
    for(int w = 0;w < image.width();++w)
        for(int h = 0; h < image.height();++h)
        {
            QRgb rgb = image.pixel(w,h);
            if(rgb == origColor.rgb())
            {
                ///替换颜色
                image.setPixel(w,h,destColor.rgba());
            }
        }
    return QPixmap::fromImage(image);
}QPixmap CKnitWi



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: