mtmurdock
mtmurdock

Reputation: 13062

QT: Painting bitmap/PNG images to a QWidget

I am building a game using QT in c++. I have extended the QWidget class as a painting surface and have set up a thread to refresh the screen. What I need now is to load the sprite sheets from file, break them up into separate 64x64 pixel images, and then paint them to the screen. Does anyone have some advice for how I should go about doing this?

TIA

Upvotes: 0

Views: 4325

Answers (1)

Stephen Chu
Stephen Chu

Reputation: 12832

Some QPainter::drawPixmap() variants has the option to specify the rectangle in the pixmap to be drawn. This will help you keeping the sprite sheets without breaking them up into small images.

For repeated sprites, QPainter::drawPixmapFragments() probably will have better performance and also allow sub-image drawing.

Upvotes: 1

Related Questions