如何清除jpeg图像?

WeG*_*ars 6 delphi

如何清除TJPEGImage图像?

JPG.Width := 0招是行不通的.另外,我不想创建一个空位图(0x0像素)并将其分配给jpeg.

TLa*_*ama 9

你可以使用这样的东西(这里使用插入的类来访问受保护的方法):

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)