Displaying a 32bit bitmap with Alpha channel transparency
-
Hi, I want to display(on a Form) a 32bit bitmap with Alpha channel transparency, so thet the transparency is honoured. I have tried a Picture control but it ignores the Alpha channel. Any ideas? Thanks - John
“If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford
What format is the image? As far as I'm aware a bitmap doesn't support the alpha channel in Windows, but you would rather manage it using a chroma key (that's where you choose one colour as being transparent). If it is a bitmap, then you might want to try out the code sample here[^] If you are using a PNG (for instance), then just set the appropriate
PixelFormat
, i.e.PixelFormat.Format32bppArgb;
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
What format is the image? As far as I'm aware a bitmap doesn't support the alpha channel in Windows, but you would rather manage it using a chroma key (that's where you choose one colour as being transparent). If it is a bitmap, then you might want to try out the code sample here[^] If you are using a PNG (for instance), then just set the appropriate
PixelFormat
, i.e.PixelFormat.Format32bppArgb;
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
Thanks Pete, The image format is 32bit bmp. But I could easly change it to png using Gimp. Where does PixelFormat come from? I checked Image.PixelFormat on msdn... http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(SYSTEM.DRAWING.IMAGE.PIXELFORMAT);k(TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22);k(DevLang-CSHARP)&rd=true[^] All it does is show how to call ToString() on it (why do they bother). Thanks - John
“If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford
-
Thanks Pete, The image format is 32bit bmp. But I could easly change it to png using Gimp. Where does PixelFormat come from? I checked Image.PixelFormat on msdn... http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(SYSTEM.DRAWING.IMAGE.PIXELFORMAT);k(TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22);k(DevLang-CSHARP)&rd=true[^] All it does is show how to call ToString() on it (why do they bother). Thanks - John
“If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford
PixelFormat
is an enumeration[^].*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Thanks Pete, The image format is 32bit bmp. But I could easly change it to png using Gimp. Where does PixelFormat come from? I checked Image.PixelFormat on msdn... http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(SYSTEM.DRAWING.IMAGE.PIXELFORMAT);k(TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22);k(DevLang-CSHARP)&rd=true[^] All it does is show how to call ToString() on it (why do they bother). Thanks - John
“If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford
-
PixelFormat
is an enumeration[^].*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Just FYI, 32bit BMP is almost universally unsupported. Even by image manipulation programs.
Yeh, I see what you mean. You would think by now that there would be a standard way of handling transparency, but ther isn't. its all over the place, Alpha channels, transparency masks of every posible value ever known, what a can of worms it is.
“If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford
-
Yeh, I see what you mean. You would think by now that there would be a standard way of handling transparency, but ther isn't. its all over the place, Alpha channels, transparency masks of every posible value ever known, what a can of worms it is.
“If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford
-
What format is the image? As far as I'm aware a bitmap doesn't support the alpha channel in Windows, but you would rather manage it using a chroma key (that's where you choose one colour as being transparent). If it is a bitmap, then you might want to try out the code sample here[^] If you are using a PNG (for instance), then just set the appropriate
PixelFormat
, i.e.PixelFormat.Format32bppArgb;
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
Pete O'Hanlon wrote:
As far as I'm aware a bitmap doesn't support the alpha channel in Windows
Since when? Bitmaps (BMP) have supported the alpha channel for probably close to a decade or more.
-
Pete O'Hanlon wrote:
As far as I'm aware a bitmap doesn't support the alpha channel in Windows
Since when? Bitmaps (BMP) have supported the alpha channel for probably close to a decade or more.
Note the careful use of Windows here - it's not the problem with Bitmaps, it's a problem with Windows.
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Yeh, I see what you mean. You would think by now that there would be a standard way of handling transparency, but ther isn't. its all over the place, Alpha channels, transparency masks of every posible value ever known, what a can of worms it is.
“If I had asked people what they wanted, they would have said faster horses.” ― Henry Ford
__John_ wrote:
You would think by now that there would be a standard way of handling transparency
I'm glad to see there are optimists still afloat ! :) imho, using PNG's with transparency has become a standard: they work in .NET, they work on the web. best, Bill
"The first principle is that you must not fool yourself, and you are the easiest person to fool." Richard Feynman