开发者

Anti aliasing DrawLine on CE

I am drawing a line to a Graphics object in Windows CE using C#.NET 3.5.

The code I am using looks like this:

e.Graphics.DrawLine(new Pen(Color.FromArgb(11, 118, 200), 2), x1, y1, x2, y2);

This works however looks terrible due to jaggies etc. Is开发者_运维问答 there anyway I can draw anti aliased lines?

From what I can tell the Graphics object doesn't support this natively but is there anyway to "cheat" this effect using some trickery?


A fast trick if you're drawing on a solid color background, you can draw a line with a thicker pen and a color in between the background color and the line color prior to the actual line, for instance, when drawing on a black background:

e.Graphics.DrawLine(new Pen(Color.FromArgb(5, 59, 100), 3), x1, y1, x2, y2);
e.Graphics.DrawLine(new Pen(Color.FromArgb(11, 118, 200), 2), x1, y1, x2, y2);

This adds a "glow" to the line (even on perfect horizontal / vertical lines though).


I feel your pain. I was doing something similar a few years ago for .NETCF and I was going down all sorts of funny paths. Ended up more work than it was worth. Have a look at this awfulness:

http://freespace.virgin.net/hugo.elias/graphics/x_wuline.htm

http://social.msdn.microsoft.com/Forums/en-US/netfxcompact/thread/b34f56c4-585b-4ff5-ac7d-b6e2ae516ccf/

Also, this might serve some answers but could be a useful replacement for the WM GDI system.

http://drawingcf.codeplex.com/

This question lead me to the http://www.amanithvg.com/project.html which offers an OpenGL like framework with Windows CE libraries. Might be mega-overkill though just for a few lines.

Finally, you could always just use a bitmap, but you might have problems with transparency later on.


Found this XrossGDI+ complete native C#:

http://www.isquaredsoftware.com/XrossOneGDIPlus.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜