ivylnm
asked on
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!
I have used the TImage's Refresh or LoadFromFile(''). But it still remain the same picture.Please guide!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Mohammed,
yes, exactly.
or
Image1.Picture.Bitmap.Assi gn(nil);
yes, exactly.
or
Image1.Picture.Bitmap.Assi
too late :-(
An alternative is
Image1.Picture.Bitmap := nil;
J.
Image1.Picture.Bitmap := nil;
J.
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.Canv as 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
with Image1.Picture.Bitmap.Canv
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
Hello, ivylnm!
I've got proposal with codes below. It's working just fine, believe me it was tested:
Image1.Picture.Bitmap.Rele aseHandle;
Sincerely, Fred
I've got proposal with codes below. It's working just fine, believe me it was tested:
Image1.Picture.Bitmap.Rele
Sincerely, Fred
ASKER
Thanks A lot!
I see nothing difficult there:
procedure TForm1.SpeedButton1Click(S
begin
Image1.Picture.Bitmap.Load
end;
------
Igor.