The Transparent property of the TImage Delphi control specifies whether the objects behind the image should show through the background of the image.
When Transparent is True, by design, the bottom-left pixel and all the pixels of the same color as "invisible".
Custom Color TImage TransparencyIf you do not want the color of the bottom-left pixel to specify which image color should be "transparent" - you can set the TransparentColor property programmatically.
Here's an example with 3 TImage controls all displaying the same bitmap image: red circled black x with magenta "surrounding".
Image 1 has Transparency set to False.
Image 2 has Transparency set to True.
Image 3 has Transparency set to True. Plus: TransparentColor and TransparentMode are programmatically set. The pixel used to set the transparent color is positioned in the middle of the image (original size 48 x 48 px.)
Note 1: If TransparentColor is assigned, the TransparentMode is automatically set to tmFixed so that the new transparent color can be used later. If you want TransparentColor to disregard any assignments and return the bottom left most pixel color again, set TransparentMode to tmAuto.
procedure TForm1.FormCreate(Sender: TObject) ; begin Image1.Transparent := False; Image2.Transparent := True; Image3.Transparent := True; with Image3.Picture.Bitmap do begin //middle of the image TransparentColor := Canvas.Pixels[24,24]; //actually not needed TransparentMode := tmFixed; end; end;
Note 2: the image used comes with Delphi, you can locate it in the Program Files\Common Files\Borland Shared\Images\GlyFX folder.