0

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)

任何人都可以帮助我更接近吗?

4

2 回答 2

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) 是错误的颜色。

于 2013-02-21T04:10:12.993 回答
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

对于更改,不需要“Img.MakeTransparent(Color)”。尝试获得带有轮廓边框的体面图像以消除不良边缘...

于 2013-02-21T16:15:05.990 回答