小弟刚刚学GDI+,请高手多包含。
下面是一个简单的重画按钮的代码
Private Sub myButton_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.FillRectangle(New SolidBrush(Me.BackColor), e.ClipRectangle)
Dim g As Graphics = e.Graphics
Dim myImage As Image = Image.FromFile("C:\1.png")
Dim myTextureBrush As TextureBrush = New TextureBrush(myImage)
g.FillRectangle(myTextureBrush, 3, 3, Width, Height)
End Sub
但是画出来之后PNG的透明效果不会出现。如何让按钮本身透明,只按照PNG的Alpha显示呢?
欢迎到我的博客一起讨论 http://www.raymanzhai.com