AnarX
11th March 2008, 09:53 AM
For a project I'd like to use directx fonction in .NET CF 3.5 programing using c#.
It's the sprite fonction that interests me but I can't use alpha channel that png files offer.
What I did :
// Declaring a Texture object and putting a png file using A8R8G8B8 image format with no alpha color (placed in OnDeviceResest)
tex = TextureLoader.FromStream(dev, Assembly.GetExecutingAssembly().GetManifestResourc eStream(@"SpriteTest.sprite.png"), D3DX.Default, D3DX.Default, D3DX.Default, D3DX.Default, Usage.None, Format.A8R8G8B8, Pool.VideoMemory, (Filter)D3DX.Default, (Filter)D3DX.Default, 0);
// in OnPaint
dev.BeginScene();
dev.Clear(ClearFlags.Target, Color.Black, 1.0F, 0);
sprite.Begin(SpriteFlags.AlphaBlend);
sprite.Draw(tex, spriteCtr, spritePos, Color.White.ToArgb());
sprite.End();
dev.EndScene();
dev.Present();
My sprite is a rounded box, on emulator I get it drawn correctly bon on device the there's White part surounding rounded corner...
I'd like to use png at maximum capacity, meaning using alpha channel.
Is it possible and how to do this ?
Edit : For further information, the sprite I try to render is my avatar
It's the sprite fonction that interests me but I can't use alpha channel that png files offer.
What I did :
// Declaring a Texture object and putting a png file using A8R8G8B8 image format with no alpha color (placed in OnDeviceResest)
tex = TextureLoader.FromStream(dev, Assembly.GetExecutingAssembly().GetManifestResourc eStream(@"SpriteTest.sprite.png"), D3DX.Default, D3DX.Default, D3DX.Default, D3DX.Default, Usage.None, Format.A8R8G8B8, Pool.VideoMemory, (Filter)D3DX.Default, (Filter)D3DX.Default, 0);
// in OnPaint
dev.BeginScene();
dev.Clear(ClearFlags.Target, Color.Black, 1.0F, 0);
sprite.Begin(SpriteFlags.AlphaBlend);
sprite.Draw(tex, spriteCtr, spritePos, Color.White.ToArgb());
sprite.End();
dev.EndScene();
dev.Present();
My sprite is a rounded box, on emulator I get it drawn correctly bon on device the there's White part surounding rounded corner...
I'd like to use png at maximum capacity, meaning using alpha channel.
Is it possible and how to do this ?
Edit : For further information, the sprite I try to render is my avatar