chami.com : منبع

توضيح:
رنگ ها در دلفي به صورت
TColor تعريف شده اند اما در صفحات HTML  همين رنگ ها به صورت رشته هاي 6 كاراكتري Hex تعريف مي شوند در اين مقاله روش اين تبديل را به آساني فرا خواهيد گرفت.

  {
  Return TColor value in XXXXXX format
  (X being a hex digit)
 }

 function
 TColorToHex( Color : TColor ): string;
 begin
  Result :=
  { red value }

  IntToHex( GetRValue( Color ), 2 ) +
  { green value }
  IntToHex( GetGValue( Color ), 2 ) +
  { blue value }
  IntToHex( GetBValue( Color ), 2 );
 end;

//****************************

 {
 sColor should be in XXXXXX format
 (X being a hex digit)
 }

 function
   HexToTColor( sColor : string ): TColor;
 begin
  Result :=
  RGB(
  { get red value }
  StrToInt( '$'+Copy( sColor, 1, 2 ) ),
  { get green value }
  StrToInt( '$'+Copy( sColor, 3, 2 ) ),
  { get blue value }
  StrToInt( '$'+Copy( sColor, 5, 2 ) ));
 end;