KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility Method to convert RGB Values into Decimal
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: November 2, 2020

Utility method to convert RGB value to decimal format. For example, the color cyan has RGB value of (0, 255, 255). The decimal equivalent is 65535.

In: 0, 255, 255 (Cyan)
Out: 65535 (Cyan)

//==========================================
//DESCRIPTION: Use the red, blue, green (rr, bb, gg) values of a color to find the decimal value of the color
//PARAMETERS:
//- $1 = Red
//- $2 = Blue
//- $3 = Green
//- $0 = Decimal value of color
//==========================================

C_LONGINT($red;$green;$blue;$0;$1;$2;$3)

$red:=$1
$green:=$2
$blue:=$3

$0:=(($red << 16)+($green << 8)+$blue)