PDA

View Full Version : DirectX, png files and their alpha channel


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

AnarX
12th March 2008, 12:17 AM
I've succeded on displaying png sprite with alpha channel (proud :D)

Now I've got an other problem...
When testing on emulator everything works great but since I put exe on my device it appends different.

On emu I'm able to get my background at the right color and my png right sized, on my device I got black background and reduced sized sprite...

I own an HTC Prophet, if someone can help to fix it or at least tells me what's wrong it'll be nice ;)

AnarX
13th March 2008, 03:01 PM
Nobody knows ? :confused:

Tintolo
15th January 2009, 10:28 PM
I've succeded on displaying png sprite with alpha channel (proud :D)

How did you do this please ?

Thanks ;)