Link to home
Start Free TrialLog in
Avatar of neopolis
neopolis

asked on

Text to Bmp

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




Avatar of Slavak
Slavak

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;
Avatar of neopolis

ASKER

Looks good
can you email a demo made i am new at delphi
thanks
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;

ASKER CERTIFIED SOLUTION
Avatar of Slavak
Slavak

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:-)
Thank you Slavak and Gwena
your explanation was easy for me to follow
i am new very much appreciated again Thank You..