Reputation: 7013
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.
Upvotes: 4
Views: 2335
Reputation: 21
While the BMP format does support an alpha channel, Windows ignores it. Luckily, the format is rather simple and you can read it using System.IO.BinaryReader then create a Drawing.Bitmap using the LockBits and UnlockBits methods to write the data to it.
Upvotes: 2
Reputation: 14373
You need to do two things:
The code is a liitle bit bulky, but here is a very nice sample application with source code: Per Pixel Alpha Blend in C#
Upvotes: 3
Reputation: 56853
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.
Upvotes: 2