functuin GetRValue(color : integer) : byte; begin result := byte(color shr 16); end; function GetGValue(color : integer) : byte; begin result := byte(color shr 8); end; function GetBValue(color : integer): byte; begin result := byte(color); end;function rgb(r,g,b:byte):integer; begin result := (integer(r) shl 16) + (integer(g) shl 8) + integer(b); end;
r,g,b:intager
r:=integer(x/256/256)
g:=integer((x-r*256*256)/256)
b:=。返回[r,g,b]
这是原理说明,具体编程不难。
请问一下,由tcolor求r,g,b呢?
我试了一下,在delphi中可直接使用rgb(r,g,b)函数,但其分解函数是什么,却不知?
GetGValue
GetBValue
合并时我是这样的
Format('$00 %02x%02x%02x',[GetRValue(i),GetGValue(i),GetBValue(i)])
返回一个字符串,你或者可改写一下。
begin
result := byte(color shr 16);
end;
function GetGValue(color : integer) : byte;
begin
result := byte(color shr 8);
end;
function GetBValue(color : integer): byte;
begin
result := byte(color);
end;function rgb(r,g,b:byte):integer;
begin
result := (integer(r) shl 16) + (integer(g) shl 8) + integer(b);
end;