绘图程序通用缩放算法
我的 GUI 工具包 wxPython 提供了一些实现用户缩放系数的方法,但是质量不太好。我正在寻找有关如何创建缩放功能的想法,我知道这很复杂。
我有一个代表我绘制的画布的位图。这显示在滚动窗口内。
我预见到的问题: - 放大和平移画布时的性能 -“真实”坐标和放大坐标的困难 - 图像质量不会随缩放而降低
在其设备上下文中使用 wxPython 的 SetUserScale() 可以呈现 图像质量像这样 - 这是一条 1px 线,放大 30%。
我只是想知道我需要采取的一般步骤以及我将遇到的挑战。感谢您的任何建议
My GUI toolkit, wxPython provides some methods for implementing a user zoom factor, however the quality isn't too good. I'm looking for ideas on how to create a zooming feature, which I know is complicated.
I have a bitmap representing my canvas which is drawn to. This is displayed inside a scrolled window.
Problems I forsee:
- performance when zoomed in and panning around the canvas
- difficulties with "real" coordinates and zoomed in coordinates
- image quality not degrading with the zoom
Using wxPython's SetUserScale() on its device contexts presents image quality like this - this is with a 1px line, at 30% zoomed in.
I'm just wondering the general steps I'll need to take and the challenges I'll encounter. Thanks for any suggestions
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 OpenGL 渲染场景。您可以进行硬件缩放和平移,这可能会非常快。 OpenGL 中也提供了各种平滑滤镜,如果您想要自定义滤镜,可以使用 GLSL。
如果您想手动执行操作,请查看双线性插值和双三次插值。
You can render your scene using OpenGL. You get hardware scaling and panning, which will probably be very fast. There are various smoothing filters available in OpenGL, too, and you can use GLSL if you want a custom filter.
If you want to do things manually, look into bilinear interpolation and bicubic interpolation.
您是否尝试过使用
GraphicsContext
?这是一些示例代码。使用
GCDC 应该很容易放入现有代码中
包装器。你可能只需要这一行:dc = wx.GCDC(dc)
渲染会慢很多!您可以将此设置为可由用户启用/禁用的选项。
替代文本 http://www.michaelfogleman.com/static/images/gcdc.png< /a>
Have you tried using
GraphicsContext
?Here's some sample code. It should be easy to drop into your existing code using the
GCDC
wrapper. You may only need the line:dc = wx.GCDC(dc)
Rendering will be a lot slower! You could make this an option that could be enabled/disabled by the user.
alt text http://www.michaelfogleman.com/static/images/gcdc.png