Hi Guys and Gals of QB64 Universe
on Discord there is this request.
I find it useful for sharing in a more stable place (the Forum).
There are alot of mentioning about transparency on putimage wiki, but cant find any examples Im looking for.
[11:43]
I mean if there is no thing for it internally, its no problem to use just multiple images with they own transparency in it. I was just thinking that there is since I remember seeing some things about transparency. But it could be for other things as wel
a bit of simple graphic functions of QB64 that mimic the AND/OR/XOR/PSET option of QB45 PUT graphic keyword.
In QB64 you needn't use the old graphic tecniques both for the more available graphic memory to use both for the simpler graphic keywords.
here I share a very simple demonstration about how to merge 2 images with different grade of transparency
A1&
= _NewImage(w
, h
, 32) ' first image THE SCREENA2&
= _NewImage(w
, h
, 32) ' second image to show on the screenA3&
= _NewImage(w
/ 2, h
/ 2, 32) ' resizing the second image into a smaller image' making background image of the screeen
Line (300, 300)-(400, 400), _RGB32(0, 0, 200, 255), BF
' making new image to paste with transparency to the SCREEN
_PutImage , A2&
, A3&
' save A2 in A3 changing its size _PutImage , A1&
, A2&
' save a1 in a2 to restore background
Screen A1&
' it creates the screen _PutImage , A2&
, A1&
' it restores background to screen visible Locate 1, 1:
Print "Alpha channel source image: "; q
' onscreen output _SetAlpha q
, , A3&
' here it is changing transparency of A3& _PutImage (200, 200)-(400, 400), A3&
, A1&
' it puts A3& on the center of A1& _Delay .2 'it waits to let you see changement _Display ' it shows at the istant the changement
On the other side if you want only have the background transparent you must use an image with Black background that it works as transparent color in QB64!
Moreover if you want to make transparent a specific color or range of colors you must use _SETALPHA keyword.
Good Coding