Qt - QImage is there a method to paste Qimage into another Qimage?

萝らか妹 提交于 2019-12-06 17:36:35

问题


I am looking for a way to simply paste some Qimage into bigger one, starting with some given (x,y). Now, I am copying pixel by pixel all Qimage.


回答1:


Yes, use a QPainter to paint into a QPaintDevice, QImage is a QPaintDevice, so it works.




回答2:


QImage srcImage = QImage(100, 100);
QImage destImage = QImage(200, 200);
QPoint destPos = QPoint(25, 25);  // The location to draw the source image within the dest

srcImage.fill(Qt::red);
destImage.fill(Qt::white);

QPainter painter(&destImage);
painter.drawImage(destPos, srcImage);
painter.end();


来源:https://stackoverflow.com/questions/3602482/qt-qimage-is-there-a-method-to-paste-qimage-into-another-qimage

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!