PDA

View Full Version : add(draw) an icon(or image) to a QPixmap?



ascii
20th November 2008, 09:02
hi, i captured screen without mouse icon.
bu i need screenshot with mouse icon.

can i add(draw) a mouse icon or image on my screenshot Qpixmap?
and How?:)

caduel
20th November 2008, 10:24
Convert the pixmap to a QImage, construct a QPainter for that image, paint whatever you like upon that image (using the painter).
Save to modified image to a file.
or: Convert back to a pixmap (if needed).

HTH

ascii
20th November 2008, 12:08
Thanks...
Can you show me an easy simple?
i want to add mouse icon?

ascii
20th November 2008, 12:13
Thanks...
Can you show me an easy simple?
i want to add mouse icon?

spirit
20th November 2008, 12:44
try something like this


...
QPixmap p("cursor-arrow.png");
QPixmap pixmap = QPixmap::grabWindow(qApp->desktop()->winId());
QPainter painter(&pixmap);
painter.drawPixmap(mapToGlobal(QCursor::pos()), p);
pixmap.save("test.png");
...