PDA

View Full Version : TImage (gif) & form.color



Wizard
25-03-2009, 09:54 AM
Hi all. I have a few TImages with .gif pictures on a Delphi form. Now what I want to do is to change the color of the form in the event handler of a button on the form, formTest.color := clPurple. Well it changes the form color but not the color of the TImage holder for some reason. I tried changing it with canvas.brush.color but the compiler moans that this can only be done with .bmp.

It works when I change the color in the form's object inspector but not when I click the button ???

Any ideas? ;D

User137
25-03-2009, 01:05 PM
Did you try changing (replace myTImage with name of your TImage)
myTImage.Transparent:=true;
myTImage.TransparentColor:=clPurple;

If that is what you mean, change background color?... Gif, jpg, png and most anything else than BMP are formats that you cannot use canvas with. They are controlled through other objects such as TJPEGImage in jpeg.pas. GIF was only introduced after Delphi 2006 and don't know which class and unit it comes through.

http://delphi.about.com/od/graphics/a/delphigif.htm

Wizard
25-03-2009, 01:49 PM
Hi, thanks for the reply User137 ;D

I'm using the Gif unit from delphi.about.com.

There is no property called TransparentColor or any property for colorin Delphi TImage properties ???

Any further ideas? ???

Here's what happens:

http://i40.tinypic.com/67imme.jpg

Wizard
26-03-2009, 11:05 AM
Ok, I got it to work ;D You have to dinamically load the gif into the image. ::)



procedure TfrmTheme.ColorButton1Click(Sender: TObject);
begin
form1.Color := clNavy;
form1.Image1.Picture.Graphic.LoadFromFile('Image1. gif');
form1.Image2.Picture.Graphic.LoadFromFile('Image2. gif');
form1.Image3.Picture.Graphic.LoadFromFile('Image3. gif');
form1.Image4.Picture.Graphic.LoadFromFile('Image4. gif');
form1.Image5.Picture.Graphic.LoadFromFile('Image5. gif');
form1.Image6.Picture.Graphic.LoadFromFile('Image6. gif');
form1.Image7.Picture.Graphic.LoadFromFile('Image7. gif');
end;