...write a transparent Text on a TImage?

Author: Thomas Stutz

Category: Graphic

procedure TForm1.Button1Click(Sender: TObject);
begin
  with 
Image1.Picture.Bitmap.Canvas do
  begin
    
Font.Color  := clBlue;
    Brush.Style := bsclear;
    Font.Size   := 13;
    TextOut(10, 10, 'Transparent Text!!');
  end;
end;

{**** Or / Oder ****}

procedure TForm1.Button1Click(Sender: TObject);
var
  
OldBkMode: integer;
begin
  with 
Image1.Picture.Bitmap do
  begin
    
Canvas.Font.Color := clBlue;
    OldBkMode         := SetBkMode(Canvas.Handle, Ord(TRANSPARENT));
    Canvas.Font.Size  := 13;
    Canvas.TextOut(10, 10, 'Transparent Text!!');
    SetBkMode(Canvas.Handle, OldBkMode);
  end;
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base