Qt,仅显示大QImage的一部分的低成本方式
我在 QImage 中绘制 WAV 文件的频谱(示例: http://savepic.net/2350314.jpg )。考虑到良好的时间分辨率,WAV 文件可能足够长,无法适合屏幕。
我需要能够足够快地扫描整个文件,可能不需要文件系统读取操作。
所以我必须在内存中保留大的 QImage 以便快速滚动。另一种设计会比较慢,因为每次用户滚动屏幕时都需要我重新绘制 QImage (QImages)。
假设设计将大 QImage 保留在内存中(例如 1024x50000),我必须能够在程序窗口中显示该大 QImage 的某些部分。
成本最低的解决方案是什么?使用 QScrollArea 或者使用 QPainter 方法 drawImage() 和偏移参数?
I draw frequency spectrum of WAV file inside QImage (example: http://savepic.net/2350314.jpg). The WAV file may be long enough to not fit into screen considering good time resolution.
I need to be able to srcoll through entire file fast enough, possibly without filesystem reading operations.
So i have to keep large QImage in memory for fast scrolling. Another desigion would be slower, because it would require me to redraw QImage (QImages) every time user scrolls a screen.
Assuming the desigion with keeping large QImage in memory (1024x50000, for example) i must be able to display some part of that large QImage in the program window.
What is the solution with lowest cost? Using QScrollArea or maybe using QPainter method drawImage() with offset arguments?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我肯定会构建一个小型自定义小部件,并使用 QPainter 重新实现其 Paint() 方法(并使用偏移量滚动等)。
使用 QPixmap 显示图像的所需部分应该更快然后本地绘制 QImage(的一部分)。
I would definitely build a small custom widget and reimplement its paint() method with a QPainter (and scrolling with offsets etc).
Using QPixmap for showing the needed parts of the image should be faster then natively drawing (a part of) a QImage.