I just did some testing: (Tests are on a Intel Core 2 Duo 3.0 Windows XP. So, it might be different on Windows 7/8/Vista)
179 JPEG images. Total size 104 MB.
OleAut32 (IPicture) = 41 seconds
Lazarus TPicture = 55 Seconds
EDIT:
TBitmap.Assign(TJpegImage) also came in at 55 seconds (actually 56 seconds)
TPicture.Bitmap.Assign(TJpegImage) also 55 seconds.
Which isn't a big difference, but, if you are loading 100 pixel width thumbs, it takes 33 seconds.
procedure BitmapThumbLoadFromFile(const ABitmap: TBitmap; const AFileName: TFileName;
const AWidth: Integer);
var
LDispatch: IDispatch;
LPicture: IPicture;
LMetricX: OLE_XSIZE_HIMETRIC;
LMetricY: OLE_YSIZE_HIMETRIC;
begin
LDispatch := nil;
if OleLoadPictureFile(AFileName, LDispatch) = S_OK then
begin
LPicture := LDispatch as IPicture;
LPicture.get_Width(LMetricX);
LPicture.get_Height(LMetricY);
ABitmap.SetSize(AWidth, AWidth * LMetricY div LMetricX);
LPicture.Render(wireHDC(ABitmap.Canvas.Handle), 0, 0, ABitmap.Width,
ABitmap.Height, 0, LMetricY, LMetricX, -LMetricY, PRect(nil)^);
end else begin
raise Exception.Create('Unable to load thumb.');
end;
end;
An alternative is to inherit from TJPEGImage to get access to the TJPEGScale (Defined in FPReadJPEG)
TJPEGScale = (jsFullSize, jsHalf, jsQuarter, jsEighth);
Which is fast, but the resulting quality can be unpredictable depending on the JPEG. What I've done in the past for a thumbnail view, is to use the fastest possible method for a draft view, so either TJPEGScale=jsEighth or maybe the OleAut32 stuff, then run a timer/thread to load improved thumbs.
type
TJPEGImageEx = class(TJPEGImage)
strict private
FScale: TJPEGScale;
protected
procedure InitializeReader(AImage: TLazIntfImage; AReader: TFPCustomImageReader); override;
public
property Scale: TJPEGScale read FScale write FScale;
end;
procedure TJPEGImageEx.InitializeReader(AImage: TLazIntfImage; AReader: TFPCustomImageReader);
begin
(AReader as TFPReaderJpeg).Scale := FScale;
inherited InitializeReader(AImage, AReader);
end;
Hope all that helps. Thats about as far as I went with JPEG loading. I know INTEL has a JPEG library, which I haven't tried: (Here is a doc that compares it to Microsoft's IPicture.
http://www.drdobbs.com/inside-intels-jpeg-library/184405097*** EDIT ****
Curiosity got the better of me. So I looked for some Delphi INTEL JPEG Library code.
After hacking some code from here, it seems the Intel Jpeg Lib loads the same images in 12 seconds!
http://bouchez.info/myjpeg.htmlHere is my hackup version of MyJpeg. There are graphics libraries that support IJL which seems like it would be a good thing to investigate.
www.wascal.net/bin/LazMyJpeg.zip