How to clear a TJPEGImage image?
The JPG.Width := 0
trick won't work.
Also I don't want to create an empty bitmap (0x0 pixels) and assign it to the jpeg.
You might use something like this (the interposed class is used here to access the protected methods):
type
TJPEGImage = class(jpeg.TJPEGImage);
implementation
procedure TForm1.Button1Click(Sender: TObject);
var
JPEGImage: TJPEGImage;
begin
JPEGImage := TJPEGImage.Create;
try
// this should recreate the internal bitmap
JPEGImage.NewBitmap;
// this should recreate the internal image stream
JPEGImage.NewImage;
// here the memory used by the image should be released
finally
JPEGImage.Free;
end;
end;
If you don't want to use FreeAndNil and keep the image empty...
Procedure EmptyJPG(jpg:TJpegImage);
var
j:TJpegImage;
begin
j := TJpegImage.Create;
try
jpg.Assign(j);
finally
j.Free;
end;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With