Solved

How to clear TImage's Picture?

Posted on 2001-06-13
8
2,135 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:
mnasman 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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 video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

9 Experts available now in Live!

Get 1:1 Help Now