Reputation: 335
Th following code is not working when the Picture shaped
form.
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)
Can anybody Help me to get more closer?
Upvotes: 0
Views: 254
Reputation: 335
Thanks man...
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
For a change 'Img.MakeTransparent(Color)' is not required. Try to getva decent image with outlined border to eliminate bad edges...
Upvotes: 0
Reputation: 905
I set the form background to the same via this code and it worked:
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
And I used (0,0) for the transparency pixel though that should not matter unless your (1,1) was the wrong color.
Upvotes: 1