I have a JPG image and have it in a picture box in a form, however, it looks like this:
How can I make it so that the white part of the picture disappears, and only the colored parts appear?
You can use MakeTransparent method on Bitmap class. So it will be something like
Bitmap b = new Bitmap("img.jpg")
b.MakeTransparent(Color.White);
pictureBox.Image = b;
But I recommend you to use PNG instead of JPG for this reason: a) better quality (for images like this) c) smaller size for images like this b) native support of transparent backgrounds.
Take a look on what is the difference between them http://www.bing.com/search?setmkt=en-US&q=PNG+vs+JPG
Try
Bitmap bmp = (Bitmap)Image.FromFile( @"C:\your_k.bmp" ); //Load a bitmap from file
bmp.MakeTransparent(Color.White) //Do the work!
//if you have a varient color combination you can use RGB Combination as follows
//bmp.MakeTransparent( Color.FromArgb( 255, 255 255 ) ); // (255 255, 255) is white!
this.pictureBox1.Image = bmp;
this.pictureBox1.BackColor = Color.Transparent; //makes humbly only your object!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.