图片不能正常工作

问题描述:

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正常的图像与边框轮廓,以消除不良边缘...

+0

你为什么选择这个作为我的答案?好吧... – U1199880 2013-03-04 19:50:26

我通过这段代码设置窗体背景相同,它的工作:

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

+0

(1,1)是图像的第一个像素的颜色,(0,0)的作品,但你可以确认边缘的质量? – SOAMad 2013-02-21 04:56:59

+0

这就是我用(1,1)希望获得一些质量的原因。我相信另一种提高质量的方式可能是一个阴影效应。现在,当我给你一个代码时,你可以帮我解决这个问题吗?......并且谢谢你的回应:)我会尽力使用这个回家! – SOAMad 2013-02-21 04:57:36

+0

我会建议为阴影或其他效果制定另一个问题。 – U1199880 2013-02-21 14:11:52