你可以使用这样的东西(这里使用插入的类来访问受保护的方法):
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;
Run Code Online (Sandbox Code Playgroud)