Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to clear TImage's Picture?

Posted on 2001-06-13
8
Medium Priority
?
3,122 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

722 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