How to Convert TColor to a Hex String and Vice Versa

Posted December 15th @ 9:12 pm by m3Rlin

Delphi uses TColor to represent colors but HTML requires a string name (139 colors have names in the web palette) or a hex number. Here’s the code to convert a TColor color value to hex a string and vise versa.
The functions use the Windows API GetRValue(), GetBValue(), GetGValue() and RGB() functions.
!Note: If your are going [...]

How to Convert a Byte Value to a Binary String Representation

Posted December 15th @ 1:04 pm by m3Rlin

Delphi offers the IntToHex() function to convert integer values to hex string representations but what if you need to convert a number to a binary not a hex? Well, here’s the code for converting byte values to strings:

function IntToBin(btValue: Byte): string;

function Next(btJ: Byte): string;
[...]