Hi, Is there any way to use this kind of format in .Net (C#)? I want to use the same skin format that uTorrent uses in my app, but i can't get the transparent background. Any ideas? Thanks for your time.
+2
A:
The PixelFormat enumeration lists the formats of 'bitmaps' you can create in .Net, so you'd want PixelFormat.Format32bppArgb:
http://msdn.microsoft.com/en-us/library/system.drawing.imaging.pixelformat.aspx
http://msdn.microsoft.com/en-us/library/3z132tat.aspx
However I'm not entirely sure that the BMP file format supports transparency - so you would have to save the file as perhaps a PNG file instead.
samjudson
2008-09-03 12:18:52
sam is correct. BMP does not support an alpha channel. Transparency in bitmaps is usually done the chroma-key way (select one color to be 100% transparent).PNG will be the optimal choice here.
Boo
2009-05-04 18:47:18
+3
A:
You need to do two things:
- Copy your bitmap onto the form as background.
- Call the UpdateLayeredWindow (user32.dll) to enable per-pixel alpha transparency.
The code is a liitle bit bulky, but here is a very nice sample application with source code: Per Pixel Alpha Blend in C#
Ishmaeel
2008-10-09 08:32:36