JXL
2009-02-14 03:16:36 UTC
I have some bitmap objects with alpha channels (loaded from png
files). I would like to draw these images
as sprite in a window. I used the roughly the following code the
create the texture:
device.RenderState.ZBufferEnable = true;
device.RenderState.SourceBlend = Blend.SourceAlpha;
device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
device.RenderState.AlphaBlendEnable = true;
Texture myTexture = Texture.FromBitmap(device, myBitmap, 0,
Pool.Managed);
...
sprite = new Sprite(device);
...
sprite.Begin(SpriteFlags.AlphaBlend);
sprite.Draw(myTexture, rect, center, pos, clr);
sprite.Flush();
sprite.End();
The problem I have is that the code only interprets full transparency
or non-transparency.
Alpha values larger than certain value (about 30) will all interpreted
as non-transparency, basically black. This has the effect that the
image icons all have ugly black boundary instead of smooth boundary
with anti-alias effects.
Can anybody give me some help to address this problem?
thanks in advance.
files). I would like to draw these images
as sprite in a window. I used the roughly the following code the
create the texture:
device.RenderState.ZBufferEnable = true;
device.RenderState.SourceBlend = Blend.SourceAlpha;
device.RenderState.DestinationBlend = Blend.InvSourceAlpha;
device.RenderState.AlphaBlendEnable = true;
Texture myTexture = Texture.FromBitmap(device, myBitmap, 0,
Pool.Managed);
...
sprite = new Sprite(device);
...
sprite.Begin(SpriteFlags.AlphaBlend);
sprite.Draw(myTexture, rect, center, pos, clr);
sprite.Flush();
sprite.End();
The problem I have is that the code only interprets full transparency
or non-transparency.
Alpha values larger than certain value (about 30) will all interpreted
as non-transparency, basically black. This has the effect that the
image icons all have ugly black boundary instead of smooth boundary
with anti-alias effects.
Can anybody give me some help to address this problem?
thanks in advance.