Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Save Label as Image/Picture

Posted on 2006-10-28
6
Medium Priority
?
373 Views
Last Modified: 2010-08-05
Hi to All,

I want to save a Label as an Image or Picture in Bitmap format, please help me.

Thanks in advanced
A.R. Rafiee
0
Comment
Question by:laserayaneh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
6 Comments
 
LVL 28

Expert Comment

by:TName
ID: 17826831
Hi, to copy the label into a TImage you could try this:

procedure TMainForm.Button1Click(Sender: TObject);
begin
   Image1.Width:=Label1.Width;
   Image1.Height:=Label1.Height;
   BitBlt(Image1.Canvas.Handle, 0, 0, Label1.Width, Label1.Height,
     Label1.Canvas.Handle, 0, 0, SRCCOPY);
end;
0
 
LVL 28

Expert Comment

by:TName
ID: 17826840
To bitmap and then to file:

procedure TMainForm.Button1Click(Sender: TObject);
var
bmp:TBitmap;
begin
   bmp:=TBitmap.Create;
   bmp.Width:=Label1.Width;
   bmp.Height:=Label1.Height;
   BitBlt(bmp.Canvas.Handle, 0, 0, Label1.Width, Label1.Height, Label1.Canvas.Handle, 0, 0, SRCCOPY);
   bmp.SaveToFile('test1.bmp');
end;
0
 
LVL 28

Expert Comment

by:TName
ID: 17826859
oh, and don't forget the

  bmp.Free;

at the end, as I did ;)
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.

 
LVL 28

Accepted Solution

by:
TName earned 200 total points
ID: 17826876
Simplified form:

procedure TMainForm.Button1Click(Sender: TObject);
begin
  with TBitmap.Create do begin
      Width:=Label1.Width;
      Height:=Label1.Height;
      BitBlt(Canvas.Handle, 0, 0, Label1.Width, Label1.Height, Label1.Canvas.Handle, 0, 0, SRCCOPY);
      SaveToFile('test1.bmp');
      Free;
   end;
end;
0
 

Author Comment

by:laserayaneh
ID: 17828332
Hi to TName

Thanks you very much 'TName' , your comment is very usefull.

bye...
0
 
LVL 28

Expert Comment

by:TName
ID: 17828366
You're welcome!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question