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 に答える