Reputation: 1717
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?
Upvotes: 8
Views: 2425
Reputation: 47
If you're not up to a perfect circle for retina display, based on Leff's answer, changing the smoothing mode to antialias or high quality will fix the pixelate circle.
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
Upvotes: 0
Reputation: 582
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);
Upvotes: 2