简体   繁体   中英

How to draw and fill a pixel-perfect, symmetric ellipse in WinForms, GDI+?

I need to draw (and fill) a pixel-perfect, non anti-alised, symmetric ellipse.

I've tried various combinations of InterpolationMode , SmoothingMode and PixelOffsetMode , but none of the combinations I have tried made sure that the ellipse stays symmetric and non anti-alised at all sizes.

Unfortunately MSDN documentation on the subject is not very accurate.

各种尺寸的椭圆都不对称

Code used for drawing:

g.InterpolationMode = InterpolationMode.NearestNeighbor;
g.SmoothingMode = SmoothingMode.None;
g.PixelOffsetMode = PixelOffsetMode.None;                                
g.DrawEllipse(new Pen(colorPalette.SelectedColor), rect);

The same goes for filling non anti-alised ellipses.

Does anyone know solution for this?

try this, is it perfect enough? :)

e.Graphics.InterpolationMode = InterpolationMode.Bilinear;
e.Graphics.PixelOffsetMode = PixelOffsetMode.Half;
e.Graphics.SmoothingMode = SmoothingMode.None;
e.Graphics.FillEllipse(Brushes.Black, rect);

如果您还没有达到视网膜显示的理想圆,则根据Leff的回答,将平滑模式更改为抗锯齿或高质量会固定像素化圆。

e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM