Alpha Mask loading for Sprite Control

Blitz3D Forums/Blitz3D Programming/Alpha Mask loading for Sprite Control

BlackD(Posted 2005) [#1]
Added JFK's 8-bit alpha image loading code to Sprite Control, if anyone wants to use it. This is only relevant for people using Sprite Control.

Add the following code into the end of "sprite control.bb" - don't overwrite anything. Syntax Error - feel free to add this to Sprite Control if you want, but credit goes to JFK. http://www.blitzbasic.co.nz/codearcs/codearcs.php?code=1286 Although one look at my fast, ugly hack of your code and you'll probably shoot me. ;)

Usage:
LoadAlphaImage3D(file$,mask$,[flags],[parent])

After loading, simply use the normal DrawImage3D command - there's no slowdown as the alpha transparency has been added into the texture data. :)

Note: the alpha-mask image must be the same size as the sprite image - and an 8-bit grey-scale mask. Just choose 8-bit in your PNG saving options.



Example:


If anyone's interested, I'll extend it to work for animated images too. >_< Think of this as a replacement for MaskImage3D where you want variable alpha transparency without memory intensive image files.

+BlackD


jfk EO-11110(Posted 2005) [#2]
wait a minute, I just got to... where's that ammo box... :P

Seriously - nice to see ppl are using my stuff. And thanks for sharing, very useful library BTW.


skyfire1(Posted 2005) [#3]
that's so cool! =)


BlackD(Posted 2005) [#4]
Ooops.. should've posted this in the Userlibs forum. I'll streamline the code, add a LoadAnimAlphaImage3D() command, and put in support for full colour (24-bit, 16-bit, etc) masks, then dump it in the Userlib's forum - so anyone thinking of using this, check there tomorrow (or the day after ;)). Mmm.. and I'll add support for the mask and the image to be in the same file, with the toggle replacing [flags] as flags must be set to 2 anyway.

+BlackD