| View previous topic :: View next topic |
| Author |
Message |
Larry W. Guest
|
Posted: Fri May 20, 2005 1:34 pm Post subject: TColor to Double |
|
|
I have some ActiveX objects which gets RGB values as Double. But i want to use TColor so i need to convert the standart TColor to the R-G-B Double values.
Do you have any idea about how to do it ?
Thanks.
|
|
| Back to top |
|
 |
Avatar Zondertau Guest
|
Posted: Fri May 20, 2005 1:46 pm Post subject: Re: TColor to Double |
|
|
| Quote: | I have some ActiveX objects which gets RGB values as Double. But i
want to use TColor so i need to convert the standart TColor to the
R-G-B Double values.
Do you have any idea about how to do it ?
|
Depends on how they encode it, but probably like this:
type
TDoubleColor = record
R, G, B: Double;
end;
function ColorToDouble(Color: TColor): TDoubleColor;
begin
Color := ColorToRGB(Color);
Result.R := (Color and $FF) / 255;
Result.G := (Color shr 8 and $FF) / 255;
Result.B := (Color shr 16 and $FF) / 255;
end;
This way the maximum amount for a color is encoded as 1, the minimum
amount is 0.
|
|
| Back to top |
|
 |
Larry W. Guest
|
Posted: Mon May 23, 2005 2:45 pm Post subject: Re: TColor to Double |
|
|
Sorry for to late response. Thank you.
"Avatar Zondertau" <avatarzt (AT) gmail (DOT) com (please reply to newsgroup)> wrote:
| Quote: | I have some ActiveX objects which gets RGB values as Double. But i
want to use TColor so i need to convert the standart TColor to the
R-G-B Double values.
Do you have any idea about how to do it ?
Depends on how they encode it, but probably like this:
type
TDoubleColor = record
R, G, B: Double;
end;
function ColorToDouble(Color: TColor): TDoubleColor;
begin
Color := ColorToRGB(Color);
Result.R := (Color and $FF) / 255;
Result.G := (Color shr 8 and $FF) / 255;
Result.B := (Color shr 16 and $FF) / 255;
end;
This way the maximum amount for a color is encoded as 1, the minimum
amount is 0.
|
|
|
| Back to top |
|
 |
Larry W. Guest
|
Posted: Mon May 23, 2005 2:46 pm Post subject: Re: TColor to Double |
|
|
I wanted to mean "sorry about the late response".
"Larry W." <larry (AT) nobody (DOT) net> wrote:
| Quote: |
Sorry for to late response. Thank you.
|
|
|
| Back to top |
|
 |
|