PictureBox中的透明背景 [英] Transparent background in a pictureBox
本文介绍了PictureBox中的透明背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有没有背景的png图像,但是在我的图片框中背景是白色的,因此我尝试将BackColor设置为Transparent,但是它不起作用.
您能说我如何在PictureBox中获得透明的吗?
I have png images without background but in my pictureboxes backgrounds are white i tryed to set BackColor to Transparent but it didn''t work.
Can u say me how i can get transparent bacground in PictureBox?
推荐答案
请按照以下三个步骤设置透明颜色.
步骤1:找到您的控件类的构造函数.
步骤2:在构造函数中,调用表单的SetStyle方法.这将使您的控件支持透明的背景色.
Follow three steps process to set the transparent color.
Step 1: Locate the constructor for your control class.
Step 2: In the constructor, call the SetStyle method of your form. This will enable your control to support a transparent backcolor.
SetStyle(ControlStyles.SupportsTransparentBackColor, true);
步骤3:在上一步中添加的代码行之后,将控件的BackColor设置为Transparent.
Step 3: After the line of code you added in the previous step, set your control''s BackColor to Transparent.
this.BackColor = Color.Transparent;
执行此操作,
将PictureBox的背景色设置为与其所在窗体的背景色相同.
例如.如果
Do This,
Set the backcolor of PictureBox to be same as the backcolor of the form on which it is.
Eg. if
this.BackColor= Color.Blue;
pictureBox1.BackColor = Color.Blue;
也可以尝试对其他具有真实透明度的图像进行一次处理.也许您的图片没有透明度!
Also try doing it once with some other image which has true transparency. Maybe your image does not have transparency!!
这篇关于PictureBox中的透明背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文