Board index » delphi » Overlaying Text on Image in Image box

Overlaying Text on Image in Image box

Hi,

        I am trying to overlay some text on an image in an image box and save
the result in a file. I use the following code, (Image1 has been
preloaded an image):
     Image1.Canvas.Font.Size := 20;
     Image1.Canvas.Font.Name := 'Courier New';
     Image1.Canvas.TextOut(20,50, 'abc');
     Image1.Picture.SaveToFile('c:\abc.bmp');
However, the resultant image has a white rectangle around the text. In
Visual Basic, there is some property you can set to avoid this. Is it
possible in Delphi.

Thanks in advance.

Alan
w...@iohk.com

 

Re:Overlaying Text on Image in Image box


Quote
>         I am trying to overlay some text on an image in an image box and save
> the result in a file. I use the following code, (Image1 has been
> preloaded an image):
>      Image1.Canvas.Font.Size := 20;
>      Image1.Canvas.Font.Name := 'Courier New';
>      Image1.Canvas.TextOut(20,50, 'abc');
>      Image1.Picture.SaveToFile('c:\abc.bmp');
> However, the resultant image has a white rectangle around the text.

You need to set the brush.style property of the canvas to bsClear, e.g.
  Image1.Canvas.brush.style:=bsClear;

HTH
Allan

Other Threads