Reputation: 591
I have a problem with AntiAliasing smoothing mode and drawing. Let say I have a signal with min and max values at the same points. So I want to display it to see where it "thicker".
So the method I use is to draw vertical lines and use antialiasing. Here is the problem, the rising edge seems to be antialiased, but the falling not. If I added some noise to the second signal the same thing observable.
![With noise][2]
Can anyone point out what am I missing? Or this problem comes from somewhere else?
Code (moved from comments):
Bitmap drawBitmap = new Bitmap(pictureBox1.Height, _
pictureBox1.Width, _
System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics drawGraph;
Point[] pts = new Point[] { new Point(0, 60), new Point(0, 59), new Point(1, 35), _
new Point(1, 47), new Point(2, 25), new Point(2, 35), _
new Point(3, 17), new Point(3, 25), new Point(4, 12), _
new Point(4, 27), new Point(5, 10), new Point(5, 22), _
new Point(6, 10), new Point(6, 11), new Point(7, 11), _
new Point(7, 16), new Point(8, 16), new Point(8, 24), _
new Point(9, 24), new Point(9, 34), new Point(10, 34), _
new Point(10, 46), new Point(11, 46), new Point(11, 59), _
new Point(12, 59), new Point(12, 72)};
using (drawGraph = Graphics.FromImage(drawBitmap)) {
drawGraph.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic;
drawGraph.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias;
for (int i = 1; i < pts.Length - 1; i += 2) {
drawGraph.DrawLine(new Pen(Color.Black, 1), pts[i], pts[i - 1]);
drawGraph.DrawLine(new Pen(Color.Black, 1), pts[i], pts[i + 1]);
}
}
pictureBox1.Image = drawBitmap;
Upvotes: 1
Views: 337
Reputation:
Apply a pixel offset mode as well:
drawGraph.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality;
The InterpolationMode
can be removed as it do nothing with lines (only with images when resized).
Upvotes: 1