im.width := im.Canvas.TextWidth(clipboard.AsText); im.height := im.Canvas.TextHeight(clipboard.AsText);
var im : TBitmap; pi : TPicture; Rec : TRect; Flags : UINT; LeTexte : String; begin im:=TBitmap.Create; Rec := Rect(0,0,0,0); // INIT TAILLE LeTexte := clipboard.AsText; Flags := DT_CALCRECT; // CALCUL TAILLE RECTANGLE DrawText(Im.Canvas.Handle, PChar(LeTexte), Length(LeTexte), Rec, Flags); im.width := Rec.Right; // DIMENSIONS BITMAP im.height := Rec.Bottom; //im.canvas.brush.Color:=clYellow; // Couleur de fond //im.canvas.brush.style:=bsSolid; im.canvas.brush.style:=bsClear; // Fond transparent Flags := 0; // DESSIN TEXTE MULTILIGNE DrawText(Im.Canvas.Handle, PChar(LeTexte), Length(LeTexte), Rec, Flags); pi:=Tpicture.Create; pi.Graphic:=im; pi.SaveToFile('c:\imag1.bmp'); pi.Free; im.Free; end;