How to draw sprite with alpha channel?
Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance
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.
.
Relevant Pages
- Re: How to draw sprite with alpha channel?
... I would like to draw these images ... as sprite in a window. ... Texture myTexture = Texture.FromBitmap(device, myBitmap, 0, ... with anti-alias effects. ... (microsoft.public.win32.programmer.directx.managed) - Re: malloc() size problems
... Sprite is a simple typedef for SDL_Surface ... message (heap corruption, or something like this). ... I found a "solution" to split images in smaller tiles, ... willing to bet that you aren't allocating as much memory as you ... (comp.lang.c) - Re: Non-congruent Lambda Lists in CLOS
... generic function, but I would like get around that for one of the ... ((disp:reader disp ... ((images:reader images ... (disp (svref (images sprite) ... (comp.lang.lisp) - Re: Lasso Flipping Revisited
... If you have your own web page, or if perhaps your ISP gives you a free web page facility, then you can host the images on the page and post a link to it. ... You only need to post the relevant parts of the code, specifically just the part that contains your two StretchBlt functions which flip the images (mask and sprite) together with the declarations for any variables they use and details of the values that are assigned to them, and of course details of the size of the PictureBoxes involved. ... (microsoft.public.vb.general.discussion) - Re: malloc() size problems
... I have a strange problem with malloc(). ... example) and returns a pointer to a struct "Sprite". ... images with a variable size, say from 75k to 500k, ... explain how to fight heap corruption and memory alignment problems? ... (comp.lang.c) |
|