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

2

18

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.

Who answered 30/8, 2010 at 16:51 Comment(0)
L
12

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

Lac answered 30/8, 2010 at 16:59 Comment(0)
K
37
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();
Kelikeligot answered 9/6, 2012 at 1:3 Comment(0)
L
12

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

Lac answered 30/8, 2010 at 16:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.