Jump to content
  • Advertisement
Sign in to follow this  
Khaos Dragon

loading in an alpha channel with a texture

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

(Note: I am using managed direct3d in c#) I am trying to load an alpha channel in with my texture and for some reason my code is crashing. Perhaps there is a better way to do this?
Bitmap Bit = (Bitmap) Image.FromFile( "image.bmp" );
for( int i = 0; i < Bit.Width; i++ )
for( int j = 0; j < Bit.Height; j++ )
{
    Color color = Bit.GetPixel(i,j);
    Bit.SetPixel( i, j, Color.FromArgb( 128, color.R, color.G, color.B ) );
}
Tex = new Texture(device, Bit.Width, Bit.Height, 1, Usage.None, Format.A8B8G8R8, Pool.Managed ); 
Surface surf = Tex.GetSurfaceLevel(0);
Graphics gfx = surf.GetGraphics();
gfx.DrawImage( Bit, 0, 0, Bit.Width, Bit.Height );
gfx.Dispose();



Share this post


Link to post
Share on other sites
Advertisement
Why not instead of using a bitmap, use a png? They have built in alpha channels, and DirectX will use the alpha channel.

I'm not sure about the managed functions for loading textures, but I know it's in there. I use the D3DXCreateTextureFromFileEx() in c++, and that loads the alpha channel as well.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!