图形平滑模式 [英] Graphics SmoothingMode

查看:314
本文介绍了图形平滑模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码:

Public Class Form1
   Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
      '      e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
      e.Graphics.TranslateTransform(140, 130)
      e.Graphics.RotateTransform(45)
      Using P As New Pen(Brushes.Black, 50)
         e.Graphics.DrawLine(P, -100, 0, 100, 0)
         P.Color = Color.Aqua
         P.Width = 30
         e.Graphics.DrawLine(P, -90, 0, 0, 0)
         e.Graphics.DrawLine(P, -0, 0, 90, 0)
      End Using
   End Sub
End Class

产生这样的图像:

但是如果我打开抗锯齿以平滑线条的边缘(在屏幕截图中不是很明显),那么我会得到:

but if I turn on anti-aliasing to smooth out the edges of the lines (it's not very obvious in the screenshot) then I get this:

可以采取什么措施来避免由抗锯齿引起的蓝线之间的模糊线.

Question is what can be done to avoid the faint line between the blue lines caused by the anti-aliasing.

推荐答案

I延长x线,使浅绿色在两条线的末端重叠,并填补了问题.

I extended the x cords so the aqua overlaps at the end of the two lines and the problem filled in.

Public Class Form7
    Private Sub Form7_Paint(sender As Object, e As PaintEventArgs) Handles Me.Paint

        e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
        e.Graphics.TranslateTransform(140, 130)
        e.Graphics.RotateTransform(45)
        Using P As New Pen(Brushes.Black, 50)
            e.Graphics.DrawLine(P, -100, 0, 100, 0)
            P.Color = Color.Aqua
            P.Width = 30
            e.Graphics.DrawLine(P, -90, 1, 0, 0)
            e.Graphics.DrawLine(P, -1, 0, 90, 0)
        End Using
    End Sub
End Class


这篇关于图形平滑模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆