1

我有抗锯齿平滑模式和绘图的问题。假设我有一个在同一点具有最小值和最大值的信号。所以我想显示它以查看它“更厚”的位置。

所以我使用的方法是绘制垂直线并使用抗锯齿。这是问题所在,上升沿似乎是抗锯齿的,但下降沿没有。如果我在第二个信号中添加了一些噪音,则可以观察到同样的事情。

无噪音

有噪音

![有噪音][2]

谁能指出我错过了什么?或者这个问题来自其他地方?

代码(从评论中移出):

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;
4

1 回答 1

1

也应用像素偏移模式:

drawGraph.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality;

可以删除,InterpolationMode因为它与线条无关(仅在调整大小时适用于图像)。

于 2012-12-18T16:00:50.443 回答