Solved

How to clear TImage's Picture?

Posted on 2001-06-13
8
2,296 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
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6185330
too late :-(
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi OLE Error 8 95
Why does formely good SQL code in Delphi 2009 not work under Windows 10? 5 87
Run video youtube webbrowse 10 58
JAudiorecorder record freezing the app 29 60
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

896 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now