CE DrawLine Smoothing

I am drawing a string for a Graphics object in Windows CE using C # .NET 3.5.

The code I use is as follows:

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

This works, however it looks awful due to jaggies etc. Anyway, can I draw lines with an alias?

From what I can say, the Graphics object does not support this natively, but is there a way to β€œtrick” this effect using some tricks?

+3
source share
3 answers

A quick trick, if you use a solid background color, you can draw a line with a thicker pen and a color between the background color and the line color to the actual line, for example, when drawing 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 β€œglow” to the line (even on perfect horizontal / vertical lines).

+5
source

I feel your pain. A few years ago I was doing something similar for .NETCF, and I was going to go down different paths. More work has ended than it was worth. Look at this scary:

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/

In addition, this may provide some answers, but may be a useful replacement for the WM GDI system.

http://drawingcf.codeplex.com/

This question leads me to http://www.amanithvg.com/project.html , which offers OpenGL as a framework with Windows CE libraries. Maybe a mega-overkill, albeit for a few lines.

Finally, you can always use a bitmap, but later you may have problems with transparency.

+2
source

Found this XrossGDI + full native C #:

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

+1
source

Source: https://habr.com/ru/post/1337787/


All Articles