How to use 32-bit alpha mixed BMP in .Net

Is it possible to use such a format in .Net (C #)? I want to use the same skin format that uTorrent uses in my application, but I cannot get a transparent background. Any ideas? Thank you for your time.

+4
source share
3 answers

You need to do two things:

  • Copy the bitmap onto the shape as a background.
  • Call UpdateLayeredWindow (user32.dll) to enable alpha transparency.

The code is a liitle bit, but it is a very nice sample application with source code: Per Pixel Alpha Blend in C #

+3
source

The PixelFormat listing lists the “bitmap” formats you can create in .Net, so you'll need 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 have to save the file, possibly a PNG file.

+2
source

While the BMP format supports the alpha channel, Windows ignores it. Fortunately, the format is pretty simple, and you can read it using System.IO.BinaryReader, then create a Drawing.Bitmap using the LockBits and UnlockBits methods to write data to it.

+2
source

Source: https://habr.com/ru/post/1276528/


All Articles