QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The _ALPHA function returns the alpha channel transparency level of a color value used on a screen page or image.

Syntax

result& = _ALPHA(color~& [, imageHandle&])

Description

Example(s)

Alpha transparency levels are always 255 in 4 or 8 bit screen modes.


SCREEN 13

clr~& = _RGBA(255, 0, 255, 192) 'returns closest palette color attribute 
PRINT "Color:"; clr~&

COLOR clr~&
PRINT "Alpha:"; _ALPHA(clr~&)

END


Color 36
Alpha: 255

Explanation: _RGBA cannot change the _ALPHA level. _ALPHA32 would return 0 on any non-32 bit image or page.

Finding the transparency of a 32 bit screen mode’s background before and after CLS.


SCREEN _NEWIMAGE(640, 480, 32)
BG& = POINT(1, 1)
PRINT "Alpha ="; _ALPHA(BG&); "Press a key to use CLS!"
K$ = INPUT$(1)                   
CLS
BG& = POINT(1, 1)
PRINT "CLS Alpha ="; _ALPHA(BG&) 


CLS Alpha = 255   

Explanation: Set the ALPHA value to 255 using CLS to make the background opaque when overlaying pages.

See Also