Recent

Author Topic: [Solved]Newbie: How to get a TImage not to display with a transparent background  (Read 3665 times)

emeyer

  • Newbie
  • Posts: 4
Hi All,

I am new to Lazarus and new to this forum, although I do have programming experience in general.

I have added a TImage to a form at design time.  It is just an icon with a white background and a bit of a border.  Definitely the pixels at the corners are white.  Anyway, both in design view and when I run the application, the Image is displayed without the white background that I would like.  The TImage has the 'Transparent' property set to False.  The background of the main form is the default grey.

Is this a bug or what am I doing wrong?

Thanks for any help with this (especially as a newbie trying to get my feet wet with Pascal and Lazarus).

I'm running Lazarus 1.4.2 on Windows 8, 64 bit.

Thanks so much

Eddie


« Last Edit: August 22, 2015, 12:14:07 am by emeyer »

bylaardt

  • Sr. Member
  • ****
  • Posts: 310
try one of this:

Code: [Select]
  Image1.Picture.Bitmap.Transparent:=false;
  Image1.Picture.Icon.Transparent:=false;

or

Code: [Select]
  Image1.Picture.Bitmap.TransparentColor:=form1.color;

emeyer

  • Newbie
  • Posts: 4
Hi bylaardt,

Thank you so much for your response.

I am embarrassed to say that thanks to your response I figured out what the problem was -- it truly was a newbie problem (so embarrassing) it wasn't a code problem or a Lazarus problem at all.

The computer I am coding on is a new system, and it turns out that the monitor brightness was not set to be very bright.  The form background was already white, but with the display settings on this monitor, it looked to me that the Lazarus form color was a light grey (and I made the assumption that this was the default form background color - light grey).  I therefore expected my TImage with the brilliant white background to stand out against the form background.  It didn't stand out, and I assumed Lazarus was treating my TImage background as transparent.  As I say, so embarrassing.

Anyway, it was your response that helped me figure it out, as your second solution mentioned the form1.color... and this made me look into what value the form1.color was actually set to.  As I say, so embarrassing.  The problem was the monitor brightness making white look like it was light grey.  Groan.

Well, that's not a mistake I'm going to make again.

Thank you SOO much for your help.

Eddie

BitBangerUSA

  • Full Member
  • ***
  • Posts: 183
'tis known as a 'gotcha' - and *everyone* has gotten fooled at least once...
Lazarus Ver 2.2.6 FPC Ver 3.2.2
Windows 10 Pro 64-bit

emeyer

  • Newbie
  • Posts: 4
Thanks BitBangerUSA for your support.  I still can't believe that I assumed that it was an issue of a transparent background being applied.  I guess that's what it LOOKED LIKE and I followed the thinking 'If it looks like a duck, it probably is a duck'.  Oh well.

Still, I'm grateful for the support.  As I say, I am new to Lazarus (and Pascal) -- So still in the 'How hard or easy is it going to be' phase of working with this language and environment.  I made the mistake of assuming I didn't know something about the tool I was working with.

Anyway, thank you to both you and bylaardt.  Once I saw it should have been working, at least I had the sense to be looking for other explanations.

Eddie

 

TinyPortal © 2005-2018