Board index » delphi » Converting RGB to TColor

Converting RGB to TColor

Hi,
  I am trying to convert an array [0..768] of byte to an array[0.255]
of TColor

any suggestions?

reply to post

TIA
mike

 

Re:Converting RGB to TColor


Var
 MyArray:array[0..768] of Byte;
  MyRGB:Array[0..255] of TRGBTriple Absolute MyArray;
-- How do you like that little trick you bet you didn't know the Pascal
language
  had !!!!!!!! hihhih..
 At least it use to work, i assume that Borland has kept it in there..
 what it does is creates a referrence to the same MyArray but the
compiler lets
you address it like its a TRGBTriple..
 To use it..
Var
  C:Tcolor;
begin
  C:=0; / clear the var first to make sure the upper byte is clear.
  TRGBTriple(C) := MyRGB[0..255 ?];
end;
the reason i say that you must be using the Triple is due to the divider
factor..
if you really want to use the standar method then
   With MyRGB[?] do C := RGB(rgbtRed, rgbtGreen, rgbtblue);
That is  a macro that D will see for you..
 Hope this gives you enough to go on...
Quote
Michael wrote:
> Hi,
>   I am trying to convert an array [0..768] of byte to an array[0.255]
> of TColor

> any suggestions?

> reply to post

> TIA
> mike

Other Threads