[Webinar] Streamline your web hosting managementRegister Today

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

How to clear TImage's Picture?

Suppose I have loaded a picture ( bmp file ) into the TImage.  And a button to blank the picture or TImage out.  How to clear the TImage then??

I have used the TImage's Refresh or LoadFromFile('').  But it still remain the same picture.Please guide!
0
ivylnm
Asked:
ivylnm
1 Solution
 
ITugayCommented:
Hi ivylnm,
I see nothing difficult there:

procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
   Image1.Picture.Bitmap.LoadFromFile('D:\nwelcome.bmp');
end;

------
Igor.
0
 
Mohammed NasmanSoftware DeveloperCommented:
Hello

  Image1.Picture.Assign(Nil);

Mohammed
0
 
ITugayCommented:
Mohammed,
yes, exactly.
or
Image1.Picture.Bitmap.Assign(nil);
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
kretzschmarCommented:
too late :-(
0
 
jswebyCommented:
An alternative is

Image1.Picture.Bitmap := nil;

J.
0
 
edsteeleCommented:
If you are looking to totally get rid of the image, then those are the solutions you want to try.  If, however, you are looking to just clear out the image, you can use the following code:

with Image1.Picture.Bitmap.Canvas do
begin
  Brush.Style := bsClear;
  Pen.Style := psClear;
  Rectangle(0, 0, Image.Width+1, Image.Height+1);
end;

If you would like it cleared to a particular color, you can change the Styles to Solid and add two extra lines:

  Brush.Color := clWhite;
  Pen.Color := clWhite;

or whatever color you want to use.

Eric
0
 
fredff13Commented:
Hello, ivylnm!
I've got proposal with codes below. It's working just fine, believe me it was tested:
Image1.Picture.Bitmap.ReleaseHandle;
Sincerely, Fred


0
 
ivylnmAuthor Commented:
Thanks A lot!
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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