对开罗绘制的画布实现缩放的最有效方法是什么?
我有一个 wx.ScrolledWindow ,使用 cairo 进行绘制。我已经实现了缩放功能,现在可以重新绘制整个内容。 但由于要绘制多达 200 条曲线,我应该考虑一种性能更高的解决方案。
我想到了这些:
- 缓冲缩放系数 -1/+1 的图像(消耗内存)
- 使用 librsvg 并缓冲 SVG 图像(我读过一些相关内容。librsvg 在 Windows 下也工作吗?)
- 之后存储 cairo.Context绘制曲线组,并在缩放时恢复它(只是一个想法......这可能吗?)
还有其他可能性吗?以及:什么是最好的解决方案?
多谢
I have a wx.ScrolledWindow
where is drawn on using cairo
. I have implemented a zoom-functionality which right now redraws the whole content.
But as there will be up to 200 curves to draw I should consider a more performant solution.
I have thought of these:
- Buffering images for the zoom factors -1/+1 (Memory consuming)
- Using librsvg and buffer an SVG image (I have read something about this. Does librsvg work under Windows too?)
- Storing the cairo.Context after drawing groups of curves, and on zoom restoring it (just an idea.. is that possible?)
Are there other possibilities, and: what is the best solution?
Thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
并不是对你的问题的具体答案,但我面临着同样的问题,只是切换到 matplotlib 其中缩放和平移功能已经实现。我不确定它是否具有超级性能。我感觉我的程序之前运行得更流畅。
我还尝试了 floatcanvas 和 floatcanvas2 但对它们都不是很满意。
Not really a concrete answer to your question, but I was faced with the same problem and just switched to matplotlib where a zoom and pan function is already implemented. I am not sure though if it is super performant. I have the feeling my program was running more smoothly before.
I also tried out floatcanvas and floatcanvas2 but was not really happy with both of them.
如果您无论如何都要进行双缓冲,为什么不在等待新重绘的矢量图像时进行快速位图缩放作为“预览”呢?我承认我不知道该怎么做。但如果你能让它发挥作用,它就应该有效! :)
If you're double-buffering anyway, why not do a quick bitmap scale as a "preview" while waiting for the newly redrawn vector image? I confess I don't know how to do this. But if you can make it work, it should work! :)