C
C#6mo ago
BlckViper

png image but background is not transparent

Can somebody help me out? The original image is attached
No description
No description
16 Replies
BlckViper
BlckViperOP6mo ago
I have a problem. I have a png but the background is not transparent as presented in the attached img. If you have an answer please ping me ^^ :pepeOkayThumb:
Keswiik
Keswiik6mo ago
What exactly are you trying to do? Just posting two pictures and saying "background is not transparent" doesn't give anyone useful info.
BlckViper
BlckViperOP6mo ago
public void ShowImage(string imagePath)
{
Bitmap image = new Bitmap(imagePath);


image.MakeTransparent(Color.Transparent);

PictureBox pictureBox = new PictureBox
{
Image = image,
SizeMode = PictureBoxSizeMode.AutoSize,

};
this.Controls.Add(pictureBox);
this.ClientSize = pictureBox.Size;
}
public void ShowImage(string imagePath)
{
Bitmap image = new Bitmap(imagePath);


image.MakeTransparent(Color.Transparent);

PictureBox pictureBox = new PictureBox
{
Image = image,
SizeMode = PictureBoxSizeMode.AutoSize,

};
this.Controls.Add(pictureBox);
this.ClientSize = pictureBox.Size;
}
If that helps kind a bit
Keswiik
Keswiik6mo ago
Is this WPF? WinForms?
BlckViper
BlckViperOP6mo ago
c# win forms with .net
Keswiik
Keswiik6mo ago
What is the background color of your picturebox?
Buddy
Buddy6mo ago
Winforms doesn't exactly support transparency, not very well at least.
BlckViper
BlckViperOP6mo ago
Should be transparent. Yeah i think thats the problem i‘m running into :hidethepain:
BlckViper
BlckViperOP6mo ago
Hm, I‘ll try it later after I‘m home from work :harold: But it isn't a button. Can you show me with a little snippet what you mean? 😄
Buddy
Buddy6mo ago
Button has nothing to do with it all controls have a BackColor property
BlckViper
BlckViperOP6mo ago
Okay Can you give me a little snippet of what you mean? Like insert it into the snippet if its that what you mean?
Buddy
Buddy6mo ago
No. Read the docs
BlckViper
BlckViperOP6mo ago
Thanks a lot for your comment but the parameter with .BackColor = Color.Transparent doesn't work
Motley
Motley6mo ago
Pretty sure you don't actually want image.MakeTransparent(Color.Transparent); you use that to make a color that is NOT already transparent into a transparent color. For example changing solid pure white to transparent. It has been a long time since I've dealt with this, so take that with a grain of salt. Also, why add a picturebox to the control isntead of just setting the background of the control? If you really need the picturebox, then make the picturebox background transparent too at the very least.
BlckViper
BlckViperOP6mo ago
@Motley I think I already tried that but it doesn’t work
Want results from more Discord servers?
Add your server