Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert a TColor variable to a string and vice versa

Status
Not open for further replies.

kristof

Programmer
Jun 2, 2000
234
0
0
BE
Hi all,

Is it possible? Because I wanna take the response i got from thread102-126560 a bit further.

I'd like to convert the result of pixels[x,y] to a string so I can perform a few checks on it.

Ie. something like this:
var
clr : TColor;
oldClr, newClr : string;

begin
oldClr = ColorToStr(clr);
if oldClr = '$00FFFFFF' then
newClr := '$00000000'
end;

Also, is it possible to set a certain pixel to transparent?

Gtz,

Kristof
 
Try this:

Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
   Edit1.Text  := IntToHex(form1.color, 8)
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
   form1.color  := StrtoInt('$'+Edit1.Text);
end;

X-) Billy H

bhogar@acxiom.co.uk
 
As far as setting a pixel to transparent, this is a bit 'iffy', what you can do is set acolor to be transparent using TBitmap.TransparentColor.

Alternitavly you could creat a bitmap mask of the are where the bitmap is going to be displayed, then set the image pixel = mask pixel, I think that makes sense!

X-) Billy H

bhogar@acxiom.co.uk
 
If the tests are that simple why not just use:

var
clr, newClr : TColor;

begin

if Clr = $00FFFFFF then
newClr := $00000000

Hint:
Put your cursor on the TColor text in your IDE and press Ctrl-F1
$00FFFFFF can also be represented as clWhite
$00000000 = clWhite

end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top