Einzelnen Beitrag anzeigen

Karstadt

Registriert seit: 8. Nov 2005
788 Beiträge
 
#11

Re: Bitmapgröße an Textgröße anpassen?

  Alt 5. Aug 2006, 12:06
Delphi-Quellcode:
var
  Bild: TBitmap;
  i,i2: Integer;
  breite: Integer;
begin

  breite := 0;

  for i:= 0 to edt_text.Lines.Count-1 do
  begin
    If Length(edt_text.Lines.Strings[i]) > breite Then
    begin
      i2 := i;
      breite := Length(edt_text.Lines.Strings[i]);
    end;
  end;

  Bild := TBitmap.create;

  with Bild do
  begin
    Canvas.Font := edt_text.Font;
    Bild.Height := Canvas.TextHeight(edt_text.Text)*edt_text.Lines.Count;
    Bild.Width := Canvas.TextWidth(edt_text.Lines.Strings[i2]);
    transparentcolor := clWhite;
    transparent := true;
    for i:= 0 to edt_text.Lines.Count-1 do
    begin
     canvas.TextOut(0,Canvas.TextHeight(edt_text.Text)*i,edt_text.Lines.Strings[i]);
    end;
  end;

  Bild_img.Picture.Bitmap := Bild;

  Bild.Free;

Nun habe ich das
  Mit Zitat antworten Zitat