Revision history for KeyPgRgb


Revision [23888]

Last edited on 2020-02-03 17:42:34 by pauldoe [Changed the RGB #macro conversions from UInt to ULng]
Additions:
[[KeyPgPpdefine|#define]] **RGB**(//r//,//g//,//b//) (([[KeyPgCulng|culng]](r) [[KeyPgOpShiftLeft|shl]] 16) [[KeyPgOpOr|or]] ([[KeyPgCulng|culng]](g) [[KeyPgOpShiftLeft|shl]] 8) [[KeyPgOpOr|or]] [[KeyPgCulng|culng]](b) [[KeyPgOpOr|or]] &hFF000000)
#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]] **RGB**(//r//,//g//,//b//) (([[KeyPgCuint|cuint]](r) [[KeyPgOpShiftLeft|shl]] 16) [[KeyPgOpOr|or]] ([[KeyPgCuint|cuint]](g) [[KeyPgOpShiftLeft|shl]] 8) [[KeyPgOpOr|or]] [[KeyPgCuint|cuint]](b) [[KeyPgOpOr|or]] &hFF000000)
#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 [21112]

Edited on 2016-03-13 09:53:32 by fxm [Formatting]

No Differences

Revision [20489]

Edited on 2016-02-10 16:07:47 by DkLwikki [Update link format]
Additions:
[[KeyPgPpdefine|#define]] **RGB**(//r//,//g//,//b//) (([[KeyPgCuint|cuint]](r) [[KeyPgOpShiftLeft|shl]] 16) [[KeyPgOpOr|or]] ([[KeyPgCuint|cuint]](g) [[KeyPgOpShiftLeft|shl]] 8) [[KeyPgOpOr|or]] [[KeyPgCuint|cuint]](b) [[KeyPgOpOr|or]] &hFF000000)
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.
See ##[[KeyPgPutgraphics|Put (Graphics)]]## example in addition.
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Rgb""**##.
- ##[[KeyPgRgba|RGBA]]##
- ##[[KeyPgColor|Color]]##
- ##[[KeyPgPpdefine|#Define]]##
Deletions:
[[KeyPgPpdefine #define]] **RGB**(//r//,//g//,//b//) (([[KeyPgCuint cuint]](r) [[KeyPgOpShiftLeft shl]] 16) [[KeyPgOpOr or]] ([[KeyPgCuint cuint]](g) [[KeyPgOpShiftLeft shl]] 8) [[KeyPgOpOr or]] [[KeyPgCuint cuint]](b) [[KeyPgOpOr or]] &hFF000000)
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.
See ##[[KeyPgPutgraphics Put (Graphics)]]## example in addition.
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Rgb""**##.
- ##[[KeyPgRgba RGBA]]##
- ##[[KeyPgColor Color]]##
- ##[[KeyPgPpdefine #Define]]##


Revision [15849]

Edited on 2012-01-26 16:39:22 by DkLwikki [Update link format]
Additions:
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##**""__Rgb""**##.
Deletions:
- Not available in the //[[CompilerOptlang -lang qb]]// dialect unless referenced with the alias ##""**__Rgb**""##.


Revision [15848]

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


Revision [15743]

Edited on 2012-01-20 11:51:20 by CountingPine [Formatting]
Additions:
##//red//##, ##//green//## and ##//blue//## are components ranging ##0##-##255##.
The ##**RGB**## function can be used to compute a valid color value for use while in hi/truecolor modes. It returns an unsigned integer in the format ##&h//AARRGGBB//##, where ##//RR//##, ##//GG//## and ##//BB//## equal the values passed to this function, in hexadecimal format. ##//AA//## is the implicit alpha value and is automatically set to ##&hFF## (opaque).
Deletions:
##//red//##, ##//green//## and ##//blue//## are components ranging ##0##..##255##.
The ##**RGB**## function can be used to compute a valid color value for use while in hi/truecolor modes. It returns an unsigned integer in the format ##&hAARRGGBB##, where ##RR##, ##GG## and ##BB## equal the values passed to this function, in hexadecimal format. ##AA## is the implicit alpha value and is automatically set to ##&hFF## (opaque).


Revision [13694]

Edited on 2008-09-07 08:30:17 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 [13687]

Edited on 2008-09-03 23:11:44 by CountingPine [name case fixup]
Additions:
#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 = RGB(128, 192, 64)
Print Using "Color: _&H\ \"; Hex(col, 8)
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
Deletions:
#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 = RGB(128, 192, 64)
Print using "Color: _&H\ \"; Hex(col, 8)
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


Revision [13686]

Edited on 2008-09-03 23:09:06 by CountingPine [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.
'' setting and retrieving Red, Green, Blue and Alpha values
Dim As Uinteger r, g, b, a
Dim As Uinteger col = RGB(128, 192, 64)
Print using "Color: _&H\ \"; Hex(col, 8)
r = RGBA_R( col )
g = RGBA_G( col )
b = RGBA_B( col )
a = RGBA_A( col )
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
Deletions:
It is possible to retrieve the red, green and blue 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.
'' setting and retrieving Red, Green and Blue values
Dim As Uinteger c = Rgb(192, 128, 64)
Print "Color: ", "&H" & Hex(c, 8)
Print "Red: ", RGBA_R( c )
Print "Green: ", RGBA_G( c )
Print "Blue: ", RGBA_B( c )
Print "Alpha: ", RGBA_A( c )


Revision [13685]

Edited on 2008-09-03 23:02:21 by CountingPine [Fix Shr link; misc edits]
Additions:
##//red//##, ##//green//## and ##//blue//## are components ranging ##0##..##255##.
It is possible to retrieve the red, green and blue 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.
**Note for Windows API programmers**: The macro named ##RGB## in the Windows references has been renamed ##BGR## in the FB headers for Windows to avoid collisions.
Deletions:
##//red//##, ##//green//## and ##//blue//## are components ranging 0-255.
It is possible to retrieve the red, green and blue values from a color value, by using a combination of ##[[KeyPgOpand And]]## and ##[[KeyPgOpshr Shr]]##. The second example below shows how to ##[[KeyPgPpdefine #Define]]## and use macros to do this.
**Note for Windows API programmers**: The macro named RGB in the Windows references has been renamed BGR in the FB headers for Windows to avoid collisions.


Revision [13682]

Edited on 2008-09-03 16:02:41 by CountingPine [Fix Shr link; misc edits]
Additions:
It is possible to retrieve the red, green and blue values from a color value, by using a combination of ##[[KeyPgOpand And]]## and ##[[KeyPgOpshr 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 and blue values from a color value, by using a combination of ##[[KeyPgOpand And]]## and ##[[KeyPgShr Shr]]##. The second example below shows how to ##[[KeyPgPpdefine #Define]]## and use macros to do this.


Revision [13681]

Edited on 2008-09-03 15:59:31 by CountingPine [How to retrieve the R, G, B values]
Additions:
It is possible to retrieve the red, green and blue values from a color value, by using a combination of ##[[KeyPgOpand And]]## and ##[[KeyPgShr Shr]]##. The second example below shows how to ##[[KeyPgPpdefine #Define]]## and use macros to do this.
{{fbdoc item="filename" value="examples/manual/gfx/rgb_get.bas"}}%%(freebasic)
'' setting and retrieving Red, Green and Blue 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 c = Rgb(192, 128, 64)
Print "Color: ", "&H" & Hex(c, 8)
Print
Print "Red: ", RGBA_R( c )
Print "Green: ", RGBA_G( c )
Print "Blue: ", RGBA_B( c )
Print "Alpha: ", RGBA_A( c )
- New to ""FreeBASIC""
- ##[[KeyPgPpdefine #Define]]##
Deletions:
- New to FreeBASIC


Revision [13081]

The oldest known version of this page was created on 2008-04-20 10:51:03 by CountingPine [How to retrieve the R, G, B values]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode