ico文件修改像素点

#include <QApplication>
#include <QPixmap>
#include <QImage>
#include <QRgb>
#include <QDebug>

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    QPixmap pixmap("D:\\Code\\Qt\\popup\\logo.ico");
    QImage image = pixmap.toImage();
    for (int y = 0; y < image.height(); ++y) {
        for (int x = 0; x < image.width(); ++x) {
            QRgb pixel = image.pixel(x, y);
            if (qAlpha(pixel) == 0){
                qDebug()<<"透明像素点"<<endl;
            }else {
                image.setPixel(x, y, qRgb(255, 255, 0));
            }
        }
    }
    pixmap = QPixmap::fromImage(image);
    pixmap.save("D:\\Code\\Qt\\popup\\modified_image.ico");
    qDebug() << "ICO image modification complete.";
    return 0;
}

 

posted @ 2023-06-13 09:53  冰糖葫芦很乖  阅读(100)  评论(0编辑  收藏  举报