enviroment: Delphi Xe7 up1 with ImageEn 5.2.0
I'm building a service application which can respond image stream via TIDHTTPServer. And I load the image stream from file with TImageEnIO.
function DoLoadStream(const vFileName:String; var vOutStream:TStream; thumbsize:Integer=100):Boolean;
var
ImageEnIO1:TImageEnIO;
ImageEnProc1: TImageEnProc;
begin
ImageEnIO1:= TImageEnIO.Create(nil);
ImageEnProc1:= TImageEnProc.Create(nil);
try
ImageEnIO1.LoadfromFile(vFileName);
ImageEnProc1.AttachedIEBitmap := ImageEnIO.IEBitmap;
ImageEnProc1.Resample(thumbsize, thumbsize,
TResampleFilter.rfTriangle, true);
ImageEnIO1.SaveToStream(vOutStream, ImageEnIO1.Params.FileType);
finally
ImageEnProc1.Free;
ImageEnIO1.Free;
end;
end;
Here is the issue. ImageEnIO1.Free will cause Access violation sometime, but not all the time. Isn't the code above thread safe?
I removed the ImageEnProc part and the issue remain.