如何清除TJPEGImage图像?
JPG.Width := 0
技巧不起作用。
另外,我不想创建一个空位图(0x0像素)并将其分配给jpeg。
答案 0 :(得分: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;
答案 1 :(得分:3)
如果您不想使用FreeAndNil并将图像保持为空......
Procedure EmptyJPG(jpg:TJpegImage);
var
j:TJpegImage;
begin
j := TJpegImage.Create;
try
jpg.Assign(j);
finally
j.Free;
end;
end;
答案 2 :(得分:0)
将Tshape组件放在TImage组件的背景上
Image1 : Timage
.
.
Image1.Picture.Graphic.Assign(nil);