Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] Delphi - Easy trick to convert Delphi and HTML colors ...
Delphi, Lazarus, Free Pascal
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter
October 24, 2013 10:42 AM
Delphi color conversion routines in GraphUtil.pas that make lief easier ... like for converting Delphi's TColor to HTML Color Value and back ...
You can find all of these routines in GraphUtil.pas.
{ Converts a TColor to a Web color constant like #FFFFFF }
function ColorToWebColorStr(Color: TColor): string;
{ Converts a TColor to a Web color name, returns a Web color value if the color is not a match. }
function ColorToWebColorName(Color: TColor): string;
function WebColorToRGB(WebColor: Integer): Integer;
function RGBToWebColorStr(RGB: Integer): string;
function RGBToWebColorName(RGB: Integer): string;
{ Converts a Web color name to its TColor equivalent, returns clNone if no match }
function WebColorNameToColor(WebColorName: string): TColor;
{ Converts a web style color string (#FFFFFF or FFFFFF) to a TColor }
function WebColorStrToColor(WebColor: string): TColor;