transparency not working when drawing a bitmap to a canvas
Original Reporter info from Mantis: Wiering
-
Reporter name: Mike Wiering
Original Reporter info from Mantis: Wiering
- Reporter name: Mike Wiering
Description:
If you create a TBitmap and set its TransparentColor and then draw it to the canvas of a TImage, the image is drawn without transparency.
Steps to reproduce:
New application, add a TButton and a TImage:
procedure TForm1.Button1Click(Sender: TObject);
var
bmp: TBitmap;
begin
bmp := TBitmap.Create();
bmp.Width := 100;
bmp.Height := 100;
with bmp.Canvas do
begin
Brush.Color := clRed;
FillRect(Rect(0, 0, 100, 100));
Brush.Color := clYellow;
FillRect(Rect(20, 20, 80, 80));
end;
bmp.Transparent := TRUE;
bmp.TransparentColor := clRed;
with Image1.Picture.Bitmap do
begin
Width := 100;
Height := 100;
Canvas.Brush.Color := clBlue;
Canvas.FillRect(Rect(0, 0, 100, 100));
Canvas.Draw(0, 0, bmp);
end;
end;
In Delphi, you get a blue square with a yellow square in the middle.
In Lazarus, you get a red square with a yellow square in the middle.
Mantis conversion info:
- Mantis ID: 31556
- OS: Windows
- OS Build: 10
- Platform: PC
- Version: 1.6.2