BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TColor to Double

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Larry W.
Guest





PostPosted: Fri May 20, 2005 1:34 pm    Post subject: TColor to Double Reply with 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 ?

Thanks.
Back to top
Avatar Zondertau
Guest





PostPosted: Fri May 20, 2005 1:46 pm    Post subject: Re: TColor to Double Reply with quote



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





PostPosted: Mon May 23, 2005 2:45 pm    Post subject: Re: TColor to Double Reply with quote




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





PostPosted: Mon May 23, 2005 2:46 pm    Post subject: Re: TColor to Double Reply with quote


Smile 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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.