GDI+:视觉选择指示器的 DrawReversible 的替代品?
我一直在寻找绘制视觉对象选择指示符的替代方法(例如选定的边缘、线条等)不使用ControlPaint.DrawReversibleFrame
< /strong> 和相关的 XOR 方法。 原因是不需要的异或“伪像”、不适用于位图的可逆性、无法控制实际的视觉外观和速度缓慢。
另一方面,如果用户决定取消选择一个或两个对象,我希望避免重新绘制整个场景(实际上是地图),因为重新绘制可能非常昂贵。
因此,我能看到的唯一替代方案是直接在位图上实现一些基本的绘图逻辑,但在更改之前存储像素以前的内容。 然后(理论上)如果用户选择取消选择该边缘,我将能够重新应用所选边缘矩形的旧内容。
我的问题是,您是否认为这是一个好主意,或者您是否看到了我的问题的其他替代方案(在 GDI+ 内)?
提前致谢
I've searched around for an alternative way of drawing selection indicators for visual objects (like selected edges, lines etc.) without the use of ControlPaint.DrawReversibleFrame
and related XOR methods. The reasons are unwanted XOR-ing "artifacts", reversibility not applying to bitmaps, no control of the actual visual look and slowness.
On the other hand I want to avoid having to repaint the whole scene (map actually) if a user decides he wants to deselect an object or two, because the repaint could be quite expensive.
So the only alternative I can see is implementing some basic drawing logic directly on a Bitmap
, but with storing the previous contents of the pixels before they change. Then (in theory) I would be able to reapply old contents of, say, an selected edge rectangle if the user chooses to deselect that edge.
My question is whether you think this is a good idea or do you see some other alternatives to my problem (within the GDI+)?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果选择指示符只是绘制在未选定对象的顶部,则可以使用两个位图,将所有未选定对象绘制在背景上,将选择指示符绘制在另一个位图上,然后将它们都绘制在屏幕上。
另外,您也可以执行相同的操作,只不过渲染选定的对象而不仅仅是指示器。
If the selection indicator is just drawn on the top of the unselected object, you can use two bitmaps, draw all the unselected objects on the background one and the selection indicators on the other, and paint them both on screen.
Else, you can do the same, except that you render the selected objects instead of just indicators.
仅将“感兴趣”的矩形存储在屏幕外缓冲区中。 当焦点丢失时重新绘制。 。 。 或者,如果您可以根据内存数据重新绘制通常显示的部分,那么应该没问题。 否则看起来你已经掌握了要点。
Only store the rectangles "of interest" in an off screen buffer. And repaint when the focus is lost. . . Or if you can redraw just the portion as it appears normally based on in memory data you should be fine. Otherwise it seems that you have the gist of it.