Revision history for KeyPgRgba


Revision [24779]

Last edited on 2020-12-07 00:53:56 by fxm [now returns an ULONG instead of an UINTEGER]
Additions:
for fbc version < 1.08:
[[KeyPgPpdefine|#define]] **RGBA**(//r//,//g//,//b//,//a//) (([[KeyPgCulng|CUlng]](r) [[KeyPgOpShiftLeft|shl]] 16) [[KeyPgOpOr|or]] ([[KeyPgCulng|CUlng]](g) [[KeyPgOpShiftLeft|shl]] 8) [[KeyPgOpOr|or]] [[KeyPgCulng|CUlng]](b) [[KeyPgOpOr|or]] ([[KeyPgCulng|CUlng]](a) [[KeyPgOpShiftLeft|shl]] 24))
for fbc version >= 1.08:
[[KeyPgPpdefine|#define]] **RGBA**(//r//,//g//,//b//,//a//) [[KeyPgCulng|CUlng]](([[KeyPgCubyte|CUByte]](r) [[KeyPgOpShiftLeft|shl]] 16) [[KeyPgOpOr|or]] ([[KeyPgCubyte|CUByte]](g) [[KeyPgOpShiftLeft|shl]] 8) [[KeyPgOpOr|or]] [[KeyPgCubyte|CUByte]](b) [[KeyPgOpOr|or]] ([[KeyPgCubyte|CUByte]](a) [[KeyPgOpShiftLeft|shl]] 24))
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 for fbc version < 1.08, or an unsigned long for fbc version >= 1.08, in the format ##&h//AARRGGBB//##, where ##//RR//##, ##//GG//##, ##//BB//##, ##//AA//## equal the values passed to this function, in hexadecimal format.
Dim As ULong col = RGBA(255, 192, 64, 128)
Deletions:
[[KeyPgPpdefine|#define]] **RGBA**(//r//,//g//,//b//,//a//) (([[KeyPgCulng|CUlng]](r) [[KeyPgOpShiftLeft|shl]] 16) [[KeyPgOpOr|or]] ([[KeyPgCulng|CUlng]](g) [[KeyPgOpShiftLeft|shl]] 8) [[KeyPgOpOr|or]] [[KeyPgCulng|CUlng]](b) [[KeyPgOpOr|or]] ([[KeyPgCulng|CUlng]](a) [[KeyPgOpShiftLeft|shl]] 24))
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 ##&h//AARRGGBB//##, where ##//RR//##, ##//GG//##, ##//BB//##, ##//AA//## equal the values passed to this function, in hexadecimal format.
Dim As UInteger col = RGBA(255, 192, 64, 128)


Revision [23884]

Edited on 2020-02-03 16:18:53 by pauldoe [Changed the RGBA #macro conversions from UInt to ULng]
Additions:
[[KeyPgPpdefine|#define]] **RGBA**(//r//,//g//,//b//,//a//) (([[KeyPgCulng|CUlng]](r) [[KeyPgOpShiftLeft|shl]] 16) [[KeyPgOpOr|or]] ([[KeyPgCulng|CUlng]](g) [[KeyPgOpShiftLeft|shl]] 8) [[KeyPgOpOr|or]] [[KeyPgCulng|CUlng]](b) [[KeyPgOpOr|or]] ([[KeyPgCulng|CUlng]](a) [[KeyPgOpShiftLeft|shl]] 24))
#define RGBA_R( c ) ( CUlng( c ) Shr 16 And 255 )
#define RGBA_G( c ) ( CUlng( c ) Shr 8 And 255 )
#define RGBA_B( c ) ( CUlng( c ) And 255 )
#define RGBA_A( c ) ( CUlng( c ) Shr 24 )
Dim As UByte r, g, b, a
Deletions:
[[KeyPgPpdefine|#define]] **RGBA**(//r//,//g//,//b//,//a//) (([[KeyPgCuint|cuint]](r) [[KeyPgOpShiftLeft|shl]] 16) [[KeyPgOpOr|or]] ([[KeyPgCuint|cuint]](g) [[KeyPgOpShiftLeft|shl]] 8) [[KeyPgOpOr|or]] [[KeyPgCuint|cuint]](b) [[KeyPgOpOr|or]] ([[KeyPgCuint|cuint]](a) [[KeyPgOpShiftLeft|shl]] 24))
#define RGBA_R( c ) ( CUInt( c ) Shr 16 And 255 )
#define RGBA_G( c ) ( CUInt( c ) Shr 8 And 255 )
#define RGBA_B( c ) ( CUInt( c ) And 255 )
#define RGBA_A( c ) ( CUInt( c ) Shr 24 )
Dim As UInteger r, g, b, a


Revision [21113]

Edited on 2016-03-13 09:54:47 by fxm [Formatting]
Additions:


Revision [20490]

Edited on 2016-02-10 16:07:49 by DkLwikki [Update link format]
Additions:
[[KeyPgPpdefine|#define]] **RGBA**(//r//,//g//,//b//,//a//) (([[KeyPgCuint|cuint]](r) [[KeyPgOpShiftLeft|shl]] 16) [[KeyPgOpOr|or]] ([[KeyPgCuint|cuint]](g) [[KeyPgOpShiftLeft|shl]] 8) [[KeyPgOpOr|or]] [[KeyPgCuint|cuint]](b) [[KeyPgOpOr|or]] ([[KeyPgCuint|cuint]](a) [[KeyPgOpShiftLeft|shl]] 24))
It is possible to retrieve the red, green, blue and alpha values from a color value, by using a combination of ##[[KeyPgOpAnd|And]]## and ##[[KeyPgOpShiftRight|Shr]]##. The second example below shows how to ##[[KeyPgPpdefine|#Define]]## and use macros to do this.
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Rgba""**##.
- ##[[KeyPgRgb|RGB]]##
- ##[[KeyPgColor|Color]]##
- ##[[KeyPgPpdefine|#Define]]##
Deletions:
[[KeyPgPpdefine #define]] **RGBA**(//r//,//g//,//b//,//a//) (([[KeyPgCuint cuint]](r) [[KeyPgOpShiftLeft shl]] 16) [[KeyPgOpOr or]] ([[KeyPgCuint cuint]](g) [[KeyPgOpShiftLeft shl]] 8) [[KeyPgOpOr or]] [[KeyPgCuint cuint]](b) [[KeyPgOpOr or]] ([[KeyPgCuint cuint]](a) [[KeyPgOpShiftLeft shl]] 24))
It is possible to retrieve the red, green, blue and alpha values from a color value, by using a combination of ##[[KeyPgOpAnd And]]## and ##[[KeyPgOpShiftRight Shr]]##. The second example below shows how to ##[[KeyPgPpdefine #Define]]## and use macros to do this.
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Rgba""**##.
- ##[[KeyPgRgb RGB]]##
- ##[[KeyPgColor Color]]##
- ##[[KeyPgPpdefine #Define]]##


Revision [15853]

Edited on 2012-01-26 16:44:38 by DkLwikki [__rgba() now works in -lang qb]
Additions:
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Rgba""**##.
Deletions:
- Not available in the //[[CompilerOptlang -lang qb]]// dialect.


Revision [15744]

Edited on 2012-01-20 11:51:59 by CountingPine [Formatting]
Additions:
##//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 ##&h//AARRGGBB//##, where ##//RR//##, ##//GG//##, ##//BB//##, ##//AA//## equal the values passed to this function, in hexadecimal format.
Deletions:
##//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.


Revision [13695]

Edited on 2008-09-07 08:30:24 by JeffMarshall [name case fixup]
Additions:
It is possible to retrieve the red, green, blue and alpha values from a color value, by using a combination of ##[[KeyPgOpAnd And]]## and ##[[KeyPgOpShiftRight Shr]]##. The second example below shows how to ##[[KeyPgPpdefine #Define]]## and use macros to do this.
Deletions:
It is possible to retrieve the red, green, blue and alpha values from a color value, by using a combination of ##[[KeyPgOpand And]]## and ##[[KeyPgOpShiftRight Shr]]##. The second example below shows how to ##[[KeyPgPpdefine #Define]]## and use macros to do this.


Revision [13688]

Edited on 2008-09-03 23:13:41 by CountingPine [How to retrieve the R, G, B and A values]
Additions:
It is possible to retrieve the red, green, blue and alpha values from a color value, by using a combination of ##[[KeyPgOpand And]]## and ##[[KeyPgOpShiftRight Shr]]##. The second example below shows how to ##[[KeyPgPpdefine #Define]]## and use macros to do this.
{{fbdoc item="filename" value="examples/manual/gfx/rgba_get.bas"}}%%(freebasic)
'' setting and retrieving Red, Green, Blue and Alpha values
#define RGBA_R( c ) ( CUInt( c ) Shr 16 And 255 )
#define RGBA_G( c ) ( CUInt( c ) Shr 8 And 255 )
#define RGBA_B( c ) ( CUInt( c ) And 255 )
#define RGBA_A( c ) ( CUInt( c ) Shr 24 )
Dim As UInteger r, g, b, a
Dim As UInteger col = RGBA(255, 192, 64, 128)
Print Using "Color: _&H\ \"; Hex(col, 8)
r = RGBA_R( col )
g = RGBA_G( col )
b = RGBA_B( col )
a = RGBA_A( col )
Print
Print Using "Red: _&H\\ = ###"; Hex(r, 2); r
Print Using "Green: _&H\\ = ###"; Hex(g, 2); g
Print Using "Blue: _&H\\ = ###"; Hex(b, 2); b
Print Using "Alpha: _&H\\ = ###"; Hex(a, 2); a
- ##[[KeyPgPpdefine #Define]]##


Revision [13684]

Edited on 2008-09-03 22:57:50 by CountingPine [Add graphic to example; misc edits]
Additions:
##//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.
'open a graphics screen (320 * 240, 32-bit)
ScreenRes 320, 240, 32
Dim As Any Ptr img
Dim As Integer x, y
img = ImageCreate(64, 64)
For x = 0 To 63
For y = 0 To 63
PSet img, (x, y), RGBA(x * 4, 0, y * 4, (x + y) * 2)
Next y
Next x
Circle img, (31, 31), 25, RGBA(0, 127, 192, 192), ,,, F 'semi-transparent blue circle
Line img, (26, 20)-(38, 44), RGBA(255, 255, 255, 0), BF 'transparent white rectangle
'draw a background (diagonal white lines)
For x = -240 To 319 Step 10
Line (x, 0)-Step(240, 240), RGB(255, 255, 255)
Next
Line (10, 10)-(310, 37), RGB(127, 0, 0), BF 'red box for text
Line (10, 146)-(310, 229), RGB(0, 127, 0), BF 'green box for Putting onto
Draw String(64, 20), "PSet"
Put(48, 48), img, PSet
Put(48, 156), img, PSet
Draw String (220, 20), "Alpha"
Put(208, 48), img, Alpha
Put(208, 156), img, Alpha
'Free the image memory
ImageDestroy img
'Keep the window open until the user presses a key
Sleep
{{image class="center" title="RGBA example output" url="/images/rgba.png" }}
- New to ""FreeBASIC""
Deletions:
##//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.
screenres 640,480,32
dim as any ptr img
dim as integer x,y
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 string(96,64),"PUT AN IMAGE WITH PSET"
put(96,96),img,pset
put(96,300),img,pset
draw string (416,64),"PUT AN IMAGE WITH ALPHA"
put(416,96),img,alpha
put(416,300),img,alpha
sleep
imagedestroy img
- New to FreeBASIC


Revision [13080]

The oldest known version of this page was created on 2008-04-20 10:50:56 by CountingPine [Add graphic to example; misc edits]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode