Recent

Author Topic: [SOLVED] RGB To Hex  (Read 3517 times)

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1271
[SOLVED] RGB To Hex
« on: August 10, 2013, 03:59:42 pm »
Quick question.  I'm using TFPColor as defined in FPImage.  In order to get a RGB value as 6 char hex, I'm currently doing

Code: [Select]
IntToHex(AStyle.Font.Color.red, 2)+IntToHex(AStyle.Font.Color.green, 2)+IntToHex(AStyle.Font.Color.blue, 2)
Which, while works,  is a little unpleasant on the eye.  Anyone know of any helper routines tucked away somewhere that can this more concisely?
« Last Edit: August 10, 2013, 07:17:28 pm by Mike.Cornflake »
Lazarus Trunk/FPC latest fixes on Windows 11
  I'm getting old and stale.  Slowly getting used to git, I'll get there...

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1271
Re: RGB To Hex
« Reply #1 on: August 10, 2013, 07:17:12 pm »
Solved.

Found the following in the very same library I'm coding in...

FPUtils.pas

function FPColorToRGBHexString(AColor: TFPColor): string;
Lazarus Trunk/FPC latest fixes on Windows 11
  I'm getting old and stale.  Slowly getting used to git, I'll get there...

 

TinyPortal © 2005-2018