Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net 图片形状不工作_Vb.net_Winforms_Image - Fatal编程技术网

Vb.net 图片形状不工作

Vb.net 图片形状不工作,vb.net,winforms,image,Vb.net,Winforms,Image,当图片成形时,以下代码不起作用 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.Backgrou

图片成形时,以下代码不起作用

    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)

有人能帮我更近一点吗?

我通过这段代码将表单背景设置为相同的,它成功了:

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

谢谢伙计

     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)”不是必需的。尝试使用轮廓边框获得一幅像样的图像,以消除不好的边缘…

(1,1)是图像的第一个像素的颜色,(0,0)可以工作,但是你能确认边缘的质量吗?这就是我使用(1,1)以获得一些质量的原因。我相信提高质量的另一种方法可能是阴影效应。现在我给你一个密码,你能帮我吗?。。。感谢您的回复:)我会在@home尝试使用这个!我建议就阴影或其他影响提出另一个问题。