|
|
|
новичок
      
участник
Last Login: 20.07.2006 11:35
Сообщ.: 2,
Visits: 5
|
|
Никто не подскажет, как это сделать - вроде как пытался так:
tmpSt:='AAE2B0';
clTmp:=RGB(StrToInt('$'+MidStr(tmpSt,1,2)),StrToInt('$'+MidStr(tmpSt,3,4)),StrToInt('$'+MidStr(tmpSt,5,6)));
MainForm.Label1.Font.Color:=clTmp;
MainForm.Label1.Update;
И получается цвет не тот, что я делал!
|
|
|
|
|
новичок
      
участник
Last Login: 20.07.2006 11:35
Сообщ.: 2,
Visits: 5
|
|
Вроде как разобрался сам - вот код:
interface
uses SysUtils, StrUtils, Graphics;
type cRGB=record
Red:String;
Green:String;
Blue:String;
end;
Function GetHexValue(HexChar:Char):Integer;
implementation
Function GetHexValue(HexChar:Char):Integer;
begin
Case HexChar of
'A', 'a':
GetHexValue := 10;
'B', 'b':
GetHexValue := 11;
'C', 'c':
GetHexValue := 12;
'D', 'd':
GetHexValue := 13;
'E', 'e':
GetHexValue := 14;
'F', 'f':
GetHexValue := 15;
'0'..'9':
GetHexValue := StrToInt(HexChar);
Else
GetHexValue := 0;
End;
End;
Function HexToRGB(Value:String;Del: String=','):cRGB;
var RGBValue:array[0..2] of String;
begin
RGBValue[0] := IntToStr(GetHexValue(Value[1])* 16 + GetHexValue(Value[2]));
RGBValue[1] := IntToStr(GetHexValue(Value[3])* 16
+ GetHexValue(Value[4]));
RGBValue[2] := IntToStr(GetHexValue(Value[5])* 16
+ GetHexValue(Value[6]));
HexToRGB.Red := RGBValue[0];
HexToRGB.Green:=RGBValue[1];
HexToRGB.Blue := RGBValue[2];
End;
Function GetRGB(Value:String):TColor;
var RGBs:cRGB;
begin
try
If Length(Value) <> 7 Then begin
Exit;
end;
RGBs := HexToRGB(RightStr(Value, 6), ',');
GetRGB := RGB(StrToInt(RGBs.red), StrToInt(RGBs.green),
StrToInt(RGBs.blue)) ;
except
Exit;
end;
End;
|
|
|
|