Visual Basic .net中图像的透明度?

Sha*_*ane 2 vb.net image

我的表单上有一个图片框,我添加了一张图片.这张照片有一个透明的背景,但不幸的是,它似乎在图片框中丢失了...我猜这是因为图片框的背景颜色属性设置为灰色(默认).我看不到"透明"的任何选项.

知道怎么做吗?

use*_*826 6

根据您要完成的任务,有几种不同的方法可以实现.

一些例子是 -

使位图透明

Dim bmp As Bitmap = Bitmap.FromFile("test.bmp")
bmp.MakeTransparent(Color.Magenta) ' magenta in bitmap will be transparent
PictureBox1.Image = bmp

使图片框透明

PictureBox1.BackColor = Color.Transparent

如果你真的需要透明图像,我建议不要使用图片框,只是直接渲染透明位图.