QT:将位图/PNG 图像绘制到 QWidget
我正在使用 C++ 中的 QT 构建游戏。我已将 QWidget 类扩展为绘画表面,并设置了一个线程来刷新屏幕。我现在需要的是从文件加载精灵表,将它们分解成单独的 64x64 像素图像,然后将它们绘制到屏幕上。有人对我应该如何做这件事有一些建议吗?
TIA
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一些
QPainter::drawPixmap()
变体具有选项指定像素图中要绘制的矩形。这将帮助您保留精灵表而不将它们分解成小图像。对于重复的精灵, QPainter::drawPixmapFragments() 可能会有更好的性能,而且允许子图像绘制。
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.