I am writing simple image editor for my project.
There you can see the image in editor:
Above TImage, I placed the few TLabel.
In preview you can see result of drawing TLabels on image:
For drawing TLabels I wrote this code:
procedure TPrintForm.BuildPreview(aSsignTo: TImage);
var
Img: TBitmap;
i: Integer;
begin
Img := TBitmap.Create;
try
Img.Assign(fSrcBitmap);
for i := 0 to Count - 1 do
begin
Img.Canvas.Font := Items[i].Text.Font;
Img.Canvas.TextOut(Items[i].Text.BoundsRect.TopLeft.X - Items[i].Text.Font.Size,
Items[i].Text.BoundsRect.TopLeft.Y - Items[i].Text.Height -
Items[i].Text.Font.Size, Items[i].Text.Caption);
end;
aSsignTo.Picture.Assign(Img);
finally
FreeAndNil(Img);
end;
end;
As result I have the image, where drawed TLabel have white background under text. How to draw TLabel without it?
Img.Canvas.Brush.Style := bsClear;
Thanks to all for answers. I found solution here:
SetBkMode(Img.Picture.Bitmap.Canvas.Handle,TRANSPARENT);
Problem resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With