Alpha Image
BlitzPlus Forums/BlitzPlus Programming/Alpha Image
| ||
Hi. We're looking a way to draw and image with an alpha channel. We have the image in .tga format with alpha channel. We want to draw the image with the alpha channel. Any of you have a function like DrawImage() that work with tga alpha channel? We don't want to use Sprite to do this. It's to the HUDs Thanks a lot, EOS. |
| ||
If you want to use it specifically as a normal image the only way you can do this is by using Read/WritePixel to individually correct the pixels where the image overlaps the background. I believe a function was made to do just that, but you'll have to hunt for it. The only other option is to texture an object like a quad or similar using the TGA file. |
| ||
Yeah, won't really advise using read pixel fast and write pixel fast. There pretty slow, alothough i suppose their ok for a small image. Sprites are the way to go, and pretty easy to set up if it's a HUD. |
| ||
So we would have something like this: spr = LoadSprite("123.tga",3,cam) PositionEntity spr, 0,0,2 SpriteViewMode spr, 1 The problem we have is that the sprite looks scaled, if the position is near the camera. But if we move away the sprite it looks ok, but the other objects covers the sprite. Any ideas? Thanks a lot. |
| ||
Z-Ordering issue, try using EntityOrder |
| ||
What other objects are covering the sprite? I won't imagine it would be 2d images. |
| ||
Well, no we have the sprite ok. We don't have problems with the order (thanks Perturbatio). But now the problems is the scale of the Sprite. We move the Sprite to 0,0,6 but is there any way to know or calculate the z position that we have to put the sprite to don't loose it's real weidth and height? Thanks a lot !!! EOS |
| ||
Try moving it back to were it was and do cleartexturefilters() See if that works? |
| ||
eos, Perhaps my SpriteControl will help here. There is a DrawImage3D command in there that operates pretty much the same as the standard 2D DrawImage command. * It will display the image (using quads) scaled correctly to the pixel size of the image file. To display your image use this example: ; Sprite Control - simple test Include "Sprite Control.bb" Graphics3D 640,480 SetBuffer BackBuffer() cam=CreateCamera() piv=CreateSpritePivot(cam) sprite3d=LoadImage3D("123.tga") DrawImage3D sprite3d,242,220 RenderWorld Flip WaitKey End *NB: The default hotspot/handle of the image is in the middle. Use HandleImage3D mysprite,-1,-1 to move it to the upper/left corner like the default 2d version. The image will be very slightly blurred compared to the 2d one. Skidracer found a good way to display the images nice and sharp. Check out the Pixies example in the code archives. |