在单独的线程中绘制图像缓冲区 (MemoryDC)
我有: 一个带有图像缓冲区的面板,其中使用 Cairo 绘制表单。 缓冲区的实现就像这里的示例:http://wiki.wxpython.org/ BufferedCanvas
我想要:当缓冲区更新时执行所有绘图的线程(在创建/调整大小/缩放时)
问题:解决这个问题的好方法是什么?
我尝试在线程中进行绘图本身,但出现断言错误,因为 dc 尚未完成。 我必须在线程中还是在哪里创建 dc? 有没有关于线程和DC的教程?
编辑:
我尝试将示例与 BufferedCanvas 结合起来:LongRunningTasks
请参阅此处:http://pastebin.com/X9kqSMKT
有时会出现 X Window 系统错误,有时效果不佳
感谢您的帮助
I have: A Panel with an image buffer where the forms are drawn on using Cairo. The buffer is realized just like the example here: http://wiki.wxpython.org/BufferedCanvas
I want: A thread which does all the drawing when the buffer is updated (on creating/resizing/zooming)
The question: What is a nice way to solve this?
I have tried doing the drawing itself in the thread and got an assertation error because the dc is not finished.
Do I have to create the dc in the thread or where?
Is there some tutorial about threads and DCs?
EDIT:
I tried combining the example with the BufferedCanvas and this: LongRunningTasks
see here: http://pastebin.com/X9kqSMKT
sometimes it gives X Window System Errors, sometimes it works poorly
Thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个包含 3 个面板的示例。首先是使用 Paint 和 Resize 事件绘制。第二个使用双缓冲,因此不会闪烁。第三个使用另一个线程来绘制位图,并且在 Paint 事件中它只显示位图。
Here is an example with 3 panels. First is drawn using Paint and Resize events. Second uses double-buffering, so it does not flicker. Third uses another thread to draw the bitmap and in Paint event it just shows the bitmap.