问题描述
我的表单上有一个图片框,我添加了一张图片。这张照片有一个透明的背景,但不幸的是,它似乎丢失在图片框中...我猜这是因为图片框的背景颜色属性设置为灰色(默认)。我看不到透明的任何选项。
I have a picture box on my form, which I add a picture to. This picture has a transparent background, but unfortunately, it seems lost in the picture box... I'm guessing that's because the picture box's background colour property is set to grey (the default). I can't see any option for "transparent" though.
我知道怎么做吗?
推荐答案
根据你想要完成的目标,有几种不同的方法可以解决这个问题。
Depending on what you are trying to accomplish there's several different ways to go about it.
一些例子是 -
使位图透明
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
如果您真的需要透明图像,我建议您不要使用图片框,只是直接渲染透明位图。
If you really need a transparent image I would suggest not using the picturebox and just render a transparent bitmap directly.
这篇关于Visual Basic .net中图像的透明度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!