How to make bmp Transparent

Posted on: Wed Jun 25 11:45:49 -0700 2008. Updated on: Wed Jun 25 11:47:53 -0700 2008.
Category: System.Drawing

So, lets say you are trying to draw a button dynamically using System.Drawing. You pull in the corners from an existing png file but the corner edges are white, so when overlaying they look funny.
Here is what we do:

Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb);

Bitmap left = new Bitmap(Server.MapPath("~/custom/controls/button/btn_tall_off_left.png"));
left.MakeTransparent(Color.White);
The color you want to make transparent in the png is what you pass into the MakeTransparent() method.

Comments:

Add a Comment:

simple_captcha.jpg
(human authentication)


Ads

Categories

About

Random foliage

This website is meant to be a reference for ASP Dot Net developers. The entries are a compilation of things I've figured out how to do and that I deem useful to keep of track for future reference. Assumptions: web development with: C Sharp (vb sucks), visual studio 05/08, .net 3.5, meant for programmers. Written by: James Reategui.