Results 1 to 4 of 4

Thread: TImage (gif) & form.color

  1. #1

    TImage (gif) & form.color

    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?
    Wake up from the dream and live your life to the full

  2. #2

    Re: TImage (gif) & form.color

    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

  3. #3

    Re: TImage (gif) & form.color

    Hi, thanks for the reply User137

    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:

    Wake up from the dream and live your life to the full

  4. #4

    Re: TImage (gif) & form.color

    Ok, I got it to work You have to dinamically load the gif into the image.

    Code:
    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;
    Wake up from the dream and live your life to the full

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •