Qt Painter和Image保存

void playPainter() {
    QSize size(200,200);
    QImage picture(size,  QImage::Format_RGB32);
    picture.fill(32);

    QPainter painter;
    painter.begin(&picture);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setBackgroundMode(Qt::TransparentMode);
    QPen pen;
    QColor color(255,0,0);
    pen.setColor(color);
    pen.setWidth(5);
    pen.setCapStyle(Qt::RoundCap);
    painter.setPen(pen);
    painter.drawEllipse(10,10, 80,80);
    painter.end();

    QImageWriter  imagefile;
    imagefile.setFileName("circle.png");
    imagefile.setFormat("png");
    imagefile.setQuality(100);
    qDebug()<< imagefile.write(picture)<<imagefile.errorString();
}

画画保存图片挺好玩的


Question:

不知道有没有算法可以把图片转成可读文本, 然后由Qt读取文本再还原图片 (不是Pixmap)

你可能感兴趣的:(Qt Painter和Image保存)