QImage和QPixmap相互转换

QImage和QPixmap相互转换_第1张图片

QImage和QPixmap相互转换_第2张图片
    QPainter p(this);
    QPixmap pixmap;
    pixmap.load("../image/路飞.jpg");

    //QPixmap->QImage
    QImage tempImage = pixmap.toImage();
    p.drawImage(0,0,tempImage);

    QImage image;
    image.load("../image/路飞.jpg");

    //QImage->QPixmap
    QPixmap tempPixmap = QPixmap::fromImage(image);
    p.drawPixmap(450,0,tempPixmap);

你可能感兴趣的:(QT)