First I want to say that the more longer I work with ImageEn, the more I like it.
But actually I experienced some strange behaviour:
I develop a server application, which handles large amounts of image data. Some requests want to retrieve images after being manipulated (e.g. resized), so in order to enhance the performance, I work with parallel threads, according to the number of CPUs.
The threads are created in a loop, almost at the same time:
for i := 0 to aResultList.Count-1 do
thr := TImageManipulationThread.Create(aResultList[i],aParamList,aSessionInfo,DoAllImageManipulations,
FLogger, OnImageManipulationThreadTerminated, false);
In each thread, following code is performed:
ieIo := TImageEnIO.Create(nil);
ieio.AttachedIEBitmap := ieBmp;
ieio.Params.JPEG_DCTMethod := ioJPEG_IFAST;
ieio.Params.Width := iWidth;
ieio.Params.Height := iHeight;
ieio.Params.JPEG_Scale := ioJPEG_AUTOCALC;
ieio.LoadFromStreamJpeg(aJpegStream);
When I compile this as a 32bit application (Delphi XE2), everything works fine. When I compile this as a 64bit application, the last line produces an access violation (ievision64.dll), when it is simultaneously run in more than one thread. When I create only one thread first, then everything goes fone, even when I create multiple threads after that.
I found a workaround for 64bit applications. When I run the following code at application startup, everything works fine:
jp := TJPEGImage.Create;
try
ms := TMemoryStream.Create;
try
jp.Assign(Image1.Picture.Bitmap);
jp.SaveToStream(ms);
ms.Position := 0;
ieBmp := TIEBitmap.Create;
try
ieio := TImageEnIO.Create(nil);
try
ieio.AttachedIEBitmap := ieBmp;
ieio.Params.Width := 300;
ieio.Params.Height := 400;
ieio.Params.JPEG_Scale := ioJPEG_AUTOCALC;
ieio.LoadFromStreamJpeg(ms);
finally
ieio.Free;
end;
finally
ieBmp.Free;
end;
finally
ms.Free;
end;
finally
jp.Free;
end;
Nevertheless, this is not a really satisfying solution. I suppose that some code in an "initialization routine" of ievision64.dll is not thread safe, and that once it is initialized, everything goes fine.
Can you have a look at this?
Kind Regards
Joachim Klingenfuss
(jokli4711@gmx.de)