![]() |
Text Mittig auf ein bild zeichnen
Also ich zeiche so ein text auf ein bild von mir:
Delphi-Quellcode:
sooo aber jetzt habe ich das Problem das ich es gerne mittig hätte das bild ist 32px lang un d ich will das der text in der mitte steht
with Image1.Picture.Bitmap.Canvas do
begin Font.Color := clBlack; Brush.Style := bsclear; Font.Size := 10; Font.Name := JvFontComboBox1.FontName; Font.Style := [fsBold]; TextOut(0, 1, edit1.Text); end; wenn ich die hälfte nehme fängt er in der mitte an ... das will ich nciht wie kann ich das realisieren das er in der mitte steht? |
Re: Text Mittig auf ein bild zeichnen
Schau Dir mal
![]() |
Re: Text Mittig auf ein bild zeichnen
ich habs jetzt so:
Delphi-Quellcode:
und bekomme den Fehler
DrawText(image1.Canvas.Handle,Pchar(edit1.text),length(edit1.Text),0,DT_CENTER);
Zitat:
|
Re: Text Mittig auf ein bild zeichnen
Wofür soll die 0 denn stehen? Da muss ein Rect rein.
|
Re: Text Mittig auf ein bild zeichnen
Zitat:
naja das wäre gelößt aber der text ist jetzt nicht ganz mittig er ist etwas nach rechts geschoben wie kann ich das beheben? |
Re: Text Mittig auf ein bild zeichnen
entweder sind leading/trailing blanks im text oder das rectangle ist falsch definiert
|
Re: Text Mittig auf ein bild zeichnen
so ist das rect definiert:
Delphi-Quellcode:
das müsste doch richtig sein oder?
r:=Rect(0,0,image1.Picture.Width,image1.Picture.Height);
|
Re: Text Mittig auf ein bild zeichnen
eigentlich schon!
sind blanks vor dem string? |
Re: Text Mittig auf ein bild zeichnen
Zeig mal den ganzen Aufruf.
|
Re: Text Mittig auf ein bild zeichnen
Keine blanks
hier der anufruf:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject); var r:trect; begin image1.Picture:=image2.Picture; r:=Rect(0,0,image1.Picture.Width,image1.Picture.Height); with Image1.Picture.Bitmap.Canvas do begin Font.Color := clBlack; Brush.Style := bsclear; Font.Size := 10; Font.Name := JvFontComboBox1.FontName; Font.Style := [fsBold]; DrawText(image1.Canvas.Handle,Pchar(edit1.text),length(edit1.Text),r,DT_CENTER ); end; image1.Refresh; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:04 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz