异或绘图在C# [英] XOR Drawing in C#
问题描述
我是一个努力学习C#.NET
I am a trying to learn C# .Net.
我在VB编写的小(爱好)模拟时钟应用,较早前(编辑:VB6中,要准确),我想我会在C#.NET重写,因为我的学习的过程。
I had written small (hobby) Analog Clock application in VB sometime ago(edit: VB6, to be precise), and I thought I will rewrite in C#.NET, as part of my learning process.
在VB应用程序的一部分,我画的在XOR Drawmode时钟的手,让我不得不的移动的秒针,我不得不重新绘制它在以前的位置,然后绘制当前的位置 - 我不必刷新整个表格。我所做的只是
In the VB application, I drew the hands of the clock in XOR Drawmode, so that I have to move the second hand, I just had to redraw it in the previous position and then draw the current position - I need not refresh the whole Form. All I did was
Me.DrawMode = vbNotXorPen
然后
Me.Line...
一个VB窗体
这是在C#中我没有找到一个相当于异或笔绘图模式。
In C# I don't find an equivalent Xor Pen Draw mode.
我发现
ControlPaint.DrawReversibleLine
地方上了网,但我不知道是否 ControlPaint
是为这样的目的(我不明白什么基础坐标系 ControlPaint
的借鉴)
somewhere on the net, but I am not sure whether ControlPaint
is meant for such purposes (and I don't understand based on what co-ordinate system ControlPaint
is drawing)
有一个相当于在异或C#.NET在画什么?
或是否有更好的方法做我在做什么(具有最佳性能)
Is there an equivalent to XOR drawing in C#.NET? Or is there a better way to do what I am doing (with the best performance)
(VB和C#是我的爱好,所以随意纠正我只要我错了)
(Both VB and C# are my hobbies. So feel free to correct me wherever I am wrong)
推荐答案
恕我直言,直至及除非你是针对一些非常慢的电脑,你不需要通过使用XOR技术来优化性能。
IMHO, until and unless you are targeting some really slow computers, you don't need to optimize performance by using XOR technique.
因为你只有一次在第二个被绘制秒针,时钟的一个完整的重绘会好得多。另外,如果直接绘制秒针会看好了,使用平滑模式设置为反别名一个更简洁的外观。
Since you'd be drawing the second hand only once in a second, a complete redraw of the clock would be much better. Also, the second hand will "look" good if drawn directly, and use smoothing mode set to Anti alias for a more cleaner look.
要优化性能,您可以创建那么对于时钟的bmp每一分钟,在其上绘制秒针。
To optimize performance, you can create a bmp for clock every one minute and then draw the second hand upon it.
这篇关于异或绘图在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!