RGBA
 
Computes a valid color value including alpha (transparency) for hi/truecolor modes

Syntax

#define RGBA(r,g,b,a) ((CUInt(r) Shl 16) Or (CUInt(g) Shl 8) Or CUInt(b) Or (CUInt(a) Shl 24))

Usage

result = RGBA(red, green, blue, alpha)

Parameters

red
red color component value
green
green color component value
blue
blue color component value
alpha
alpha component value

Return Value

the combined color

Description

red, green, blue and alpha are components ranging 0-255.

The RGBA function can be used to compute a valid color value including an alpha channel for use while in hi/truecolor modes. It returns an unsigned integer in the format &hAARRGGBB, where RR, GG, BB, AA equal the values passed to this function, in hexadecimal format.

Example

ScreenRes 640,480,32

Dim As Any Ptr img
Dim As Integer x,y

'make an image that varies in transparency and color
img = ImageCreate(128,128,0)
For x = 0 To 127
  For y = 0 To 127
    PSet img,(x,y),RGBA(x*2,0,y*2,x+y)
  Next y
Next x
Circle img,(64,64),50,RGBA(0,127,192,192),,,,f
Line img,(50,40)-(78,88),RGBA(255,255,255,0),bf

'draw a background
For x=-480 To 639 Step 20
  Line (x,0)-(x+480,480),RGB(255,255,255)
Next
Line (10,10)-(630,86),RGB(127,0,0),bf
Line (10,290)-(630,438),RGB(0,127,0),bf

'draw the image and some text with PSET
Draw String(96,64),"PUT AN IMAGE WITH PSET"
Put(96,96),img,PSet
Put(96,300),img,PSet

'draw the image and some text with ALPHA
Draw String (416,64),"PUT AN IMAGE WITH ALPHA"

Put(416,96),img,Alpha
Put(416,300),img,Alpha

Sleep

ImageDestroy img


Dialect Differences

  • Not available in the -lang qb dialect.

Differences from QB

  • New to FreeBASIC

See also