Learn how to a build a cloud-first strategyRegister Now

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

Save Label as Image/Picture

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
laserayaneh
Asked:
laserayaneh
  • 5
1 Solution
 
TNameCommented:
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
 
TNameCommented:
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
 
TNameCommented:
oh, and don't forget the

  bmp.Free;

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

 
TNameCommented:
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
 
laserayanehAuthor Commented:
Hi to TName

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

bye...
0
 
TNameCommented:
You're welcome!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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