image transparency

Blitz3D Forums/Blitz3D Beginners Area/image transparency

grindalf(Posted 2008) [#1]
is there a way to get 2d image transparency in b3d

I cant find a command for it but in the drawblock command it says this

Description:
This is similar to the DrawImage command except that any transparency or MaskImage is ignored and the entire image (including masked colors) is drawn. The frame is optional.

so if transparency is ignored it seems as if there is a command to draw an image with transparency.


blackbag(Posted 2008) [#2]
I think the transparancy talked about here is where b3d does not draw any black pixels. From the mask image command....

Blitz Basic assumes that when you load an image (using LoadImage or LoadAnimImage) for drawing (using DrawImage command), you want the color black (RGB color 0,0,0) on your image to be transparent (or see through).


IPete2(Posted 2008) [#3]
grindalf,

There are a number of options for using 2D images in B3d, with transparency:

(1) Use sprites

With the loadsprite command and use a flag setting of 3 on the end thus:

Global my2dimage = loadsprite("mysprite.png",3)

This creates a 2D sprite for you in the 3D environment, so unlike 2D imageloading where the screen surface is the only plane to place your images on, with 3D sprites you can have lots of fun, placing grass, trees in the bgd, as billboards, or static 2D images all over your 3D scene in 3d.

(2) Use a single surface sprite library such as Sprite Candy

Now it may be you need to get a single surface sprite library as this may be the best option for you, depending upon what you want to achieve. I'm sure there are some free ones too, check out the code archives and the Toolbox section of this forum.

(3) Not transparency as such but by assigning black (RGB 0,0,0,) as the invisible colour when drawing purely 2D images loaded using the LoadImage command, you can make all the black in your image disappear. This is really called masking though and it has drawbacks, you cannot easily have see through bits, (you'd need a sort of grid of black and off black for that) and when antialias graphics are made (RGB packages excel in these) the edges generally are not hard cut to black, but faded. This can give bits of almost black in your final on screen 2d image which is not nice.

For true transparnet images I would suggest B3D's built in Sprites or something like Sprite Candy (which has so much more to offer than just placing transparent sprites on screen - animation, particles, effects, all sorts of great things - http://www.x-pressive.com/SpriteCandy/index.html)

Good luck,

IPete2.


grindalf(Posted 2008) [#4]
thanks for the help guys.

i had the feeling that blitz did not support transparency, it was just the help file that threw me off a bit.