PBFX 1.71a - Alpha Channel Support for 3D surfaces
This example is a quick rehash of older example that used the AFX image format to load images with Alpha channel. In this version you can load the image directly to a 3D surface (ie. Hardware Accel) and render it. While currently this is only hooked up through the DrawImage method (ie. DrawAlphaImage/DrawRotatedImage namely), the main difference is that you can now tell the renderer what type of transparency to use.
The transparent flag contains packed 3 bit settings, which you can combine will tell it how to render the surface.
1 (bit 0) = Use colour mask
2 (Bit 1) = use alpha channel
4 = not in use.
8 (bit 3) = Apply filtering
openscreen 800,600,32,1
; Include the Free Image Slib
#include "FreeImage"
Screen=newimage(800,600)
; Use Free Image to load this image, so the Alpha channel is preserved.
Logo=FreeImage_LoadImage("PlayBasicSig.png",2)
; Clear Screen
rendertoimage screen
ct=rgb(100,200,50)
cb=rgb(200,200,250)
Shadebox 0,0,getscreenwidth(),GetSCreenHeight(),ct,ct,cb,cb
rendertoscreen
Do
setcursor 0,0
drawimage screen,0,0,0
mx=mousex()
my=mousey()
w=getimagewidth(logo)
h=getimageheight(logo)
DrawAlphaImage logo,mx,my ,1,1 ; Use Mask colour transparent
DrawAlphaImage logo,mx,my+h ,1,2 ; Use Alpha channel
DrawAlphaImage logo,mx,my+(h*2) ,1,2+8 ; Use Alpha channel + filtering
For lp=0 to 10
Scale#=1+(lp/100.0)
DrawRotatedImage logo,400+(lp*1),400+lp,angle#+5,scale#,scale#,w/-2,h/-2,2
next
angle#=angle#+0.1
print fps()
Sync
loop