View Issue Details

IDProjectCategoryView StatusLast Update
0018651LazarusLCLpublic2020-03-31 13:59
ReporterPhilip Assigned ToFelipe Monteiro de Carvalho  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
Product Version0.9.28.2 
Summary0018651: TrayIcon doesn't transfer transparent colour from bitmap to trayicon properly
DescriptionIf I create a windows .ico file with some transparent pixels
and do

TrayIcon1.Icon.LoadFromFile('icon.ico');
TrayIcon1.Show;

then the icon is displayed correctly.
However, if I load a TBitmap and assign a colour as transparent
then do

TrayIcon1.Icon.Assign(bmp);
TrayIcon1.Show;

the icon doesn't display properly.
It appears to corrupt the entire rows in the bitmap that contain pixels with the transparent colour.

I can draw the same bitmap to Image1.Canvas and it is displayed properly with transparency as expected.
Additional Informationexample code
icon.bmp is a 16x16 bitmap file with 24 bit RGB colour and a grey box in the middle. see zip file

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
  ExtCtrls, StdCtrls;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    Image1: TImage;
    TrayIcon1: TTrayIcon;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var
  buffer: THandle;
  bmp: TBitmap;
  memstream: TMemoryStream;
begin
  bmp := TBitmap.Create;
  bmp.LoadFromFile('icon.bmp');
  bmp.Transparent := True;
  bmp.TransparentColor := clGray;

  Image1.Canvas.Draw(0, 0, bmp);

  TrayIcon1.Icon.Transparent:=True;
  TrayIcon1.Icon.TransparentColor:= clGray;
  TrayIcon1.Icon.Assign(bmp);
  TrayIcon1.Show;

  bmp.Free;
end;

initialization
  {$I unit1.lrs}

end.
            
Tagstransparent
Fixed in Revision
LazTarget
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0017891 assignedFelipe Monteiro de Carvalho TTrayIcon - no transparency on GTK 
related to 0024241 new TBitBtn do not display bitmap correctly 

Activities

2011-01-31 19:11

 

icon.zip (329 bytes)

Mario Bonati

2011-08-23 14:27

reporter   ~0051049

Some news?

Thanks, Mario

Issue History

Date Modified Username Field Change
2011-01-31 19:11 Philip New Issue
2011-01-31 19:11 Philip File Added: icon.zip
2011-01-31 19:11 Philip Widgetset => Win32/Win64
2011-02-07 18:00 Felipe Monteiro de Carvalho Relationship added related to 0017891
2011-02-07 18:01 Felipe Monteiro de Carvalho Status new => assigned
2011-02-07 18:01 Felipe Monteiro de Carvalho Assigned To => Felipe Monteiro de Carvalho
2011-08-23 14:27 Mario Bonati Note Added: 0051049
2020-03-31 11:10 Juha Manninen Relationship added related to 0024241
2020-03-31 13:59 Juha Manninen Tag Attached: transparent