图片不能正常工作
问题描述:
当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)
任何人都可以帮助我更加接近吗?
答
感谢的人...
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(色彩)' 不是必需的。尝试getva正常的图像与边框轮廓,以消除不良边缘...
答
我通过这段代码设置窗体背景相同,它的工作:
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)是错误的颜色。
你为什么选择这个作为我的答案?好吧... – U1199880 2013-03-04 19:50:26