Converting a Bitmap to Have a Transparent Background

Environment: .NET Beta 2

This article tells you how to make a bitmap of a picturebox with transparent background

If you search for a transparent method in the picturebox clas, you will see that the method do not exist. So there must be another way to make the background of a bitmap transparent. Have a look in the bitmap class and you will find a transparent method "MakeTransparent". You must first convert your image to a bitmap and then select the background (transparent) color. After that, make the background color transparent and finally convert it back to the image of the control.

Example code:

1) Convert your image to a bitmap

Bitmap Logo = new Bitmap(CompanyLogo.Image);

2) select the background color (here the left top pixel) and make it transparent

Logo.MakeTransparent(Logo.GetPixel(1, 1));

3) Finally convert it back to the image

CompanyLogo.Image = (Image) Logo;

That's all



Comments

  • myself

    Posted by Bill on 09/03/2014 01:01pm

    I was googling for just that - how to make a picture transparent... This method must be for "pro's". I don't even understand what program if any it refers to.

    Reply
  • Works well !

    Posted by Ram on 05/26/2014 10:40pm

    Works great ! Thanks Ram

    Reply
  • extract an image from a bmp image

    Posted by Legacy on 10/07/2003 12:00am

    Originally posted by: sumaira

    plz i want to know who to extract an image from a bmp image in a 2 tone colors
    
    interested ppl contact me

    Reply
  • Problem with bitmaps

    Posted by Legacy on 01/22/2003 12:00am

    Originally posted by: Sue

    I have found when I tried this example that the bitmap never unlocks the resource image (and yes I am doing bitmap.Dispose(); bitmap = null;

    Anyone have any ideas?

    Reply
  • Java to C#

    Posted by Legacy on 11/22/2001 12:00am

    Originally posted by: Jo

    I heard there is a tool in J# that allows you to change all your java code into C# but i can't find it...does anyone know how to?

    Reply
  • short & elegant (even thou I did not check it) :o)

    Posted by Legacy on 10/29/2001 12:00am

    Originally posted by: Amit Gefen

    A kind of advices that I like -
    short & elegant. I hope to hear some readers
    reports, if it is work as fine as it simple.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • As mobile devices have pushed their way into the enterprise, they have brought cloud apps along with them. This app explosion means account passwords are multiplying, which exposes corporate data and leads to help desk calls from frustrated users. This paper will discover how IT can improve user productivity, gain visibility and control over SaaS and mobile apps, and stop password sprawl. Download this white paper to learn: How you can leverage your existing AD to manage app access. Key capabilities to …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds