Click here to Skip to main content
15,891,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have an image and I know it path. This image has a transparent background.
I want to display it in a pictureBox and copy it to the clipboard.

My code is :
String path = ...;
Bitmap myImage = new Bitmap(path);
pictureBox1.Image = myImage;
Clipboard.SetDataObject(myImage);


But, when I paste the image, the background color is "control" , the same color as my window.

How to change it and have a transparent background, as the first image ?

Kind regard,

jérôme
Posted

An image has no transparency, that's defined by some file formats.
 
Share this answer
 
A quick solution would be:
MIDL
Bitmap b = new Bitmap(this.textBox1.Text);
b.MakeTransparent(this.BackColor);
pictureBox1.Image = b;
Clipboard.SetDataObject(b);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900