Once and for all! Fastest way to load large jpeg
- From: jimbo@xxxxxxxxxx
- Date: 9 Dec 2006 22:51:07 -0800
Here is what I'm using. It's the culmination of ablout 50 threads I've
chased.
Sender is a TImage (Thumbnail) and when it's loaded the tag property is
set
to it's offset in a thumb grid. On larger images, 4 - 8 MB it's slow.
Would
reading a stream be faster? Would loading using the WIN API be faster?
If so
an example would be nice. Also is there any way Delphi/Windows can
cache a
directory of images before they're actually loaded? Get in the back
door so
to speak? I'm open to any and every suggestion. TIA
Jim
procedure MyPicLoader(Sender: TObject);
Var
Offset, Size: Integer;
Pic: TPicture;
F: file of byte;
Begin
Offset := (Sender as TImage).Tag;
// get size of file. I assume there's a better/faster way.
AssignFile(f, filelistbox1.Directory + '\' +
filelistbox1.Items[offset]);
Reset(f);
Size := Round(filesize(f)/1000);
closefile(f);
Pic := TPicture.Create;
Pic.LoadFromFile(filelistbox1.Directory + '\' +
filelistbox1.Items[Offset]);
with TJpegImage(Pic.Graphic) do
Begin
if (Size > 2000) then
Scale := jseighth
else if (Size > 800) and (Size <= 2000) then
Scale := jsquarter
else if (Size > 400) and (Size <= 800) then
Scale := jshalf;
Performance := jpBestSpeed;
DIBNeeded; // Not sure if I need this
End;
// BigPic is a 400x300 TImage on the form
BigPic.Picture.Assign(Pic);
Pic.Free;
End;
.
- Follow-Ups:
- Re: Once and for all! Fastest way to load large jpeg
- From: J French
- Re: Once and for all! Fastest way to load large jpeg
- From: Nicholas Sherlock
- Re: Once and for all! Fastest way to load large jpeg
- Prev by Date: Re: (geen onderwerp)
- Next by Date: Re: Once and for all! Fastest way to load large jpeg
- Previous by thread: Create some nice icons and win a free licence ;-)
- Next by thread: Re: Once and for all! Fastest way to load large jpeg
- Index(es):
Relevant Pages
|