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.

John X
  • 499
  • 2
  • 7
  • 15

2 Answers2

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();
PhotoMonkee
  • 436
  • 1
  • 4
  • 2
12

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

Dr. Snoopy
  • 55,122
  • 7
  • 121
  • 140