Conv-Color RGB-16 to Hex-8

From Vectorlab
Jump to: navigation, search

Converts color triplets in the range 0-65535 (16-bit) to 8-bit hexadecimal value. You need the routines U_c255 and U_Dec2Hex to be loaded first. By Orso B. Schmid

{ Orso *********************************************** }
{ Converts a triplet of RGB values (16-bit) into Hex (8-bit), rgb values must be in range 0-65535, as from most VW standard routines }
{ for example: rgb 65535, 65535, 65535 converts into FFFFFF }
{ the routine can be lossy }
FUNCTION C_RGBtoHex(r, g, b: LONGINT; VAR hexR, hexG, hexB: STRING): STRING;
		hexR := U_Dec2Hex(U_c255(r));
		hexG := U_Dec2Hex(U_c255(g));
		hexB := U_Dec2Hex(U_c255(b));
		C_RGBtoHex := Concat(hexR, hexG, hexB);