Alpha Channel in DirectX
-
i'm making a 2d sprite game with directx but i can't figure out how to use the alpha channel so that parts of my images are transparent. what is the best type of image to use, .png, .bmp? and how do i apply an alpha channel to them. thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.
-
i'm making a 2d sprite game with directx but i can't figure out how to use the alpha channel so that parts of my images are transparent. what is the best type of image to use, .png, .bmp? and how do i apply an alpha channel to them. thanks, Rob Tomson -- There are 10 kinds of people. Those who understand binary and those who don't.
.bmp does not support alpha channels, nor does .jpg, .gif, or .tiff. .gif only supports an indexed color to serve as a transparency, which is the same as what is done for 24-bit and lower .ico files. .png does support alpha channels. You can find lots of information about image formats by searching the web, but this forum is not the appropriate place for questions not related to using C#. You can also use
Image.IsAlphaPixelFormat
on each member of thePixelFormat
enumeration to see which ones that GDI+ (which .NET uses for the graphics classes) supports support alpha channels. If you're question is about how to use such images in C# then see theImage
class in the .NET Framework SDK. Managed DirectX can also make use of these, as well as native code. UseBitmap.GetHbitmap
to get anIntPtr
that represents theHBITMAP
(native handle to a bitmap data structure, which describes about any image format) for calls to native APIs that require anHBITMAP
. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]