Conv-Color Hex-8 to RGB-16

From Vectorlab
Jump to: navigation, search


Converts a hex triplet to a RGB value in range 0-65535 (16-bit). You need the routines U_65535 and U_HexToDec to be loaded first. By Orso B. Schmid


{ Orso *********************************************** }
{ Converts a triplet of Hex values to RGB, hex values must be in form FF 9A 7B }
{ returns the rgb in range 0-65535 (16-bit) }
PROCEDURE C_Hex8ToRGB16(hexR, hexG, hexB: STRING; VAR r, g, b: LONGINT);
	BEGIN
		r := C_65535(U_HexToDec(hexR));
		g := C_65535(U_HexToDec(hexG));
		b := C_65535(U_HexToDec(hexB));
	END;


{ Orso *********************************************** }
{ the same as before, but it takes a whole 6-digits hex string: FF9A7B }
PROCEDURE C_Hex8ToRGB16_2(hexStr: STRING; VAR r, g, b: LONGINT);
	BEGIN
		IF Len(hexStr) > 5 THEN
			C_HexToRGB(Copy(hexStr, 1, 2), Copy(hexStr, 3, 2), Copy(hexStr, 5, 2), r, g, b);
	END;