Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

Text to Bmp

If i use a text entry box how can i save the text as a .bmp




0
neopolis
Asked:
neopolis
  • 2
  • 2
  • 2
1 Solution
 
SlavakCommented:
Try it,

 Bmp := TBitmap.Create;
 Try
  With Bmp Do Begin
   Canvas.Font.Assign(Edit1.Font);
   Width  := Canvas.TextWidth(Edit1.Text);
   Height := Canvas.TextHeight(Edit1.Text);
   Canvas.TextOut(0, 0, Edit1.Text);
   SaveToFile(FileName);
  End;
 finally
  Bmp.Free;
 end;
0
 
neopolisAuthor Commented:
Looks good
can you email a demo made i am new at delphi
thanks
0
 
GwenaCommented:
Hi neopolis :-)

 Here is slavak's code installed in a buttonclick procedure
maybe this will help you... just start delphi and add a button and an edit box to your form... then double click the button to make an event handler... then just replace that button code with this... it will save the text that is in the edit box to a file called TxtBmp.bmp ..it saves it to the floppy drive but you can change it to any drive :-)



procedure TForm1.Button1Click(Sender: TObject);
var MyBmp: tbitmap;
begin
  MyBmp := TBitmap.Create;
  Try
  With MyBmp Do
    Begin
      Canvas.Font.Assign(Edit1.Font);
      Width  := Canvas.TextWidth(Edit1.Text);
      Height := Canvas.TextHeight(Edit1.Text);
      Canvas.TextOut(0, 0, Edit1.Text);
      SaveToFile('A:\TxtBmp.bmp');
    End;
  finally
  MyBmp.Free;
  end;
end;

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
SlavakCommented:
Thanks, Gwena :)
0
 
GwenaCommented:
:-)
0
 
neopolisAuthor Commented:
Thank you Slavak and Gwena
your explanation was easy for me to follow
i am new very much appreciated again Thank You..
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now