QPainter painter(this); QImage image("image.jpg"); painter.drawImage(QPoint(0,0), image);
QImage image("image.jpg"); QPixmap pixmap = QPixmap::fromImage(image); QPainter painter(&pixmap); painter.drawImage(QPoint(0,0), image); pixmap.save("image.png");In this example, we create a QImage object from file, convert it into a QPixmap, create a QPainter object to draw on the pixmap, use drawImage to paint the image onto the pixmap at the top left corner (0,0), and then save the result as a PNG file. Package library: Qt.