QPixmap 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);
}

 

posted on 2020-07-24 20:55  chifandeyu  阅读(1438)  评论(0编辑  收藏  举报