以下代码在Picture shaped
表单时无效。
Dim Img As New System.Drawing.Bitmap(My.Resources.imgpng)'ImgPng is a resource Image
' The color at Pixel(1,1) is rendered as transparent for the complete background.
Img.MakeTransparent(Img.GetPixel(1, 1))
Me.BackgroundImage = Img
Me.TransparencyKey = Img.GetPixel(1, 1)
有人可以帮我更近一点吗?
答案 0 :(得分:1)
我通过此代码将表单背景设置为相同,并且有效:
Dim Img As New System.Drawing.Bitmap(My.Resources.imgpng)'ImgPng is a resource Image
' The color at Pixel(1,1) is rendered as transparent for the complete background.
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Dim Color = Img.GetPixel(0, 0)
Me.BackColor = Color
Img.MakeTransparent(Color)
Me.TransparencyKey = Color
Me.BackgroundImage = Img
我使用(0,0)作为透明度像素,但除非你的(1,1)颜色错误,否则无关紧要。
答案 1 :(得分:0)
谢谢你...
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Img As New System.Drawing.Bitmap(My.Resources.NewImage) 'NewImage is a resource Image
' The color at Pixel(1,1) is rendered as transparent for the complete background.
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Dim Color = Img.GetPixel(0, 0)
Me.BackgroundImageLayout = ImageLayout.Stretch ' To Adjust the Image
Me.BackColor = Drawing.Color.Black
Img.MakeTransparent(Drawing.Color.Black)
Me.TransparencyKey = Drawing.Color.Black
Me.BackgroundImage = Img
End Sub
对于更改'Image.Make Transparent(Color)'不是必需的。尝试获得带有轮廓边框的合适图像,以消除不良边缘......