Recent

Author Topic: Transparency in TImage  (Read 12858 times)

timppl

  • Jr. Member
  • **
  • Posts: 70
Transparency in TImage
« on: May 17, 2011, 12:59:58 pm »
Hi
I am porting an application from delphi to lazarus. For the splash screen, there is an image which is set as transparent on the form.

In the form designer it correctly shows as transparent, but when compiled and run it shows with an olive background instead of transparent. I have tried to set the following properties in the FormCreate method

  image.Picture.Bitmap.MaskHandle:=0;
  Image.Picture.Bitmap.Transparent := True;
  Image.Picture.Bitmap.TransparentColor := clOlive;

but this does not work.

Any suggestions?

Thanks

Tim
PS I don't have delphi available; The app is proprietary closed source.


Addition

Looking into it further, the TImage itself is not used directly but is used as the bitmap for the brush in a TShape. So the question now is :  does the brush in a TShape support transparency?  I have looked in the documentation and can't find the answer.

Tim
« Last Edit: May 19, 2011, 08:33:27 am by timppl »
Mageia 2 Linux on x86

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1072
    • Burdjia
Re: Transparency in TImage
« Reply #1 on: May 23, 2011, 12:34:56 pm »
Are you sure it's "clOlive"?  Note that colour description must be exact!
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

timppl

  • Jr. Member
  • **
  • Posts: 70
Re: Transparency in TImage
« Reply #2 on: May 25, 2011, 08:20:22 am »
Are you sure it's "clOlive"?  Note that colour description must be exact!

I think the color was clOlive. I created an image and repainted the background ( the part I wanted to be transparent ) in Gimp, using the hex code from the graphics unit ( $008080 ). I assume this would give the correct value.  

Unfortunately I know very little about graphics programming so I have a steep learning curve.

I also tried the method with a memory stream on the graphics page in the wiki, but that didn't work either.

I should have said as well I am using the latest svn of lazarus on linux with gtk2 interface.

Thanks

Tim
« Last Edit: May 25, 2011, 08:23:50 am by timppl »
Mageia 2 Linux on x86

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1072
    • Burdjia
Re: Transparency in TImage
« Reply #3 on: May 25, 2011, 06:02:08 pm »
Are you sure it's "clOlive"?  Note that colour description must be exact!

I think the color was clOlive. I created an image and repainted the background ( the part I wanted to be transparent ) in Gimp, using the hex code from the graphics unit ( $008080 ). I assume this would give the correct value.
That's the problem: you "assume", but computer needs exact values not assumptions.

If you're using colour "$008080" then you should use that value as transparent. I never used colour values in LCL but I think you need to use TColor. BTW I recommend you to read this wiki page if you didn't yet.
« Last Edit: May 25, 2011, 06:03:56 pm by Ñuño_Martínez »
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

timppl

  • Jr. Member
  • **
  • Posts: 70
Re: Transparency in TImage
« Reply #4 on: June 01, 2011, 12:04:12 pm »
Thanks

After further playing I realized I have actually asked the wrong question, so I will start a new thread for the right question.

Regards

Tim
Mageia 2 Linux on x86

hlazo

  • Newbie
  • Posts: 1
Re: Transparency in TImage
« Reply #5 on: July 01, 2016, 12:24:28 pm »
Transparency in TImage works only with BMP images;  the last pixel (bottom, lefth) where the transparent color.

 

TinyPortal © 2005-2018