Conv-Color RGB-16 to Hex-8

From Vectorlab

Revision as of 06:17, 1 June 2009 by Orso (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
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;
    BEGIN
        hexR := U_Dec2Hex(U_c255(r));
        hexG := U_Dec2Hex(U_c255(g));
        hexB := U_Dec2Hex(U_c255(b));
        
        C_RGBtoHex := Concat(hexR, hexG, hexB);
    END;
Personal tools