Solved

How to clear TImage's Picture?

Posted on 2001-06-13
8
2,580 Views
Last Modified: 2010-05-18
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
Comment
Question by:ivylnm
8 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 6185052
Hi ivylnm,
I see nothing difficult there:

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

------
Igor.
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 50 total points
ID: 6185058
Hello

  Image1.Picture.Assign(Nil);

Mohammed
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6185073
Mohammed,
yes, exactly.
or
Image1.Picture.Bitmap.Assign(nil);
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 6185330
too late :-(
0
 
LVL 4

Expert Comment

by:jsweby
ID: 6186949
An alternative is

Image1.Picture.Bitmap := nil;

J.
0
 
LVL 1

Expert Comment

by:edsteele
ID: 6187666
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
 

Expert Comment

by:fredff13
ID: 6187845
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
 

Author Comment

by:ivylnm
ID: 6200776
Thanks A lot!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

713 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