C
Chris Auer
I have been banging my head for a couple of hours now. No matter what I
do the color that I make transparent is black. Here is the code I am
using from MSDN. I have tried bitmaps, jpegs, gifs and new bitmaps
created in code, but I cant get any image to go transparent. Thanks if
you can help.
// Create a Bitmap object from an image file.
Bitmap myBitmap = new
Bitmap(System.Web.HttpContext.Current.Server.MapPath("resources/img/")
+ "\\Icons\\blank.bmp");
// Draw myBitmap to the screen.
Graphics g;
g = Graphics.FromImage(myBitmap);
g.DrawImage(
myBitmap,
0,
0,
myBitmap.Width,
myBitmap.Height);
// Get the color of a background pixel.
Color backColor = myBitmap.GetPixel(1, 1);
// Make backColor transparent for myBitmap.
myBitmap.MakeTransparent(backColor);
// Draw the transparent bitmap to the screen.
g.DrawImage(
myBitmap,
myBitmap.Width,
0,
myBitmap.Width,
myBitmap.Height);
do the color that I make transparent is black. Here is the code I am
using from MSDN. I have tried bitmaps, jpegs, gifs and new bitmaps
created in code, but I cant get any image to go transparent. Thanks if
you can help.
// Create a Bitmap object from an image file.
Bitmap myBitmap = new
Bitmap(System.Web.HttpContext.Current.Server.MapPath("resources/img/")
+ "\\Icons\\blank.bmp");
// Draw myBitmap to the screen.
Graphics g;
g = Graphics.FromImage(myBitmap);
g.DrawImage(
myBitmap,
0,
0,
myBitmap.Width,
myBitmap.Height);
// Get the color of a background pixel.
Color backColor = myBitmap.GetPixel(1, 1);
// Make backColor transparent for myBitmap.
myBitmap.MakeTransparent(backColor);
// Draw the transparent bitmap to the screen.
g.DrawImage(
myBitmap,
myBitmap.Width,
0,
myBitmap.Width,
myBitmap.Height);