Hello,
main form class has a image list as variable (sample project is attached):
During the form creation event a bitmap was created with the intent of transparency and then it was added into the image list using AddMasked method:
procedure TForm1.FormCreate(Sender: TObject);
const
BITMAP_SIZE = 51;
COLOR_BACKGROUND = clGreen;
//COLOR_TRANSPARENT = clBtnFace; // <-- works
COLOR_TRANSPARENT = clGrayText; // <--- fails
COLOR_OBJECT = clRed;
var
bitmap: TBitmap;
begin
Caption := LCLPlatformDisplayNames[WidgetSet.LCLPlatform];
Color := COLOR_BACKGROUND;
FImageList := TImageList.Create(self);
FImageList.Width := BITMAP_SIZE;
FImageList.Height := BITMAP_SIZE;
bitmap := TBitmap.Create;
bitmap.Width := BITMAP_SIZE;
bitmap.Height := BITMAP_SIZE;
bitmap.TransparentMode := tmFixed;
bitmap.TransparentColor := COLOR_TRANSPARENT;
//
bitmap.Canvas.Brush.Color := COLOR_TRANSPARENT;
bitmap.Canvas.FillRect(0, 0, BITMAP_SIZE, BITMAP_SIZE);
//
bitmap.Canvas.Brush.Color := COLOR_OBJECT;
bitmap.Canvas.Pen.Color := COLOR_OBJECT;
bitmap.Canvas.Ellipse(0, 0, BITMAP_SIZE, BITMAP_SIZE);
FImageList.AddMasked(bitmap, COLOR_TRANSPARENT);
bitmap.Free;
end;
In the form's OnPaint event the image is drawn from the image list:
procedure TForm1.FormPaint(Sender: TObject);
begin
FImageList.Draw(Canvas, 0, 0, 0);
end;
If I use a color other than clGrayText for transparent parts of the image then I get transparency when I draw on the canvas (first image).
But clGrayText as transparency color removes transparency (second image).
When using the GTK2 widgetset I don't see this strange effect.
Is this a bug?