Once and for all! Fastest way to load large jpeg



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;

.



Relevant Pages

  • Re: Once and for all! Fastest way to load large jpeg
    ... Nicholas Sherlock wrote: ... Sender is a TImage and when it's loaded the tag property is ... to it's offset in a thumb grid. ... Scale:= jsquarter ...
    (alt.comp.lang.borland-delphi)
  • Re: Once and for all! Fastest way to load large jpeg
    ... Sender is a TImage and when it's loaded the tag property is ... to it's offset in a thumb grid. ... On larger images, 4 - 8 MB it's slow. ... Scale:= jsquarter ...
    (alt.comp.lang.borland-delphi)
  • RE: SMTP Error from my server?
    ... This idea works fine for normal email addresses, ... with certain types of automated email which is not intended for people ... The larger problem as well is that it doesn't scale. ... A good implementation of sender ...
    (freebsd-questions)
  • Re: Track Bar
    ... private void tracker_MouseDown(object sender, MouseEventArgs e) ... ShouldDrag = false; ... // Move it based on the offset, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: Anilam DRO scale reassembly Q
    ... I had to remove the DRO's scale and inadvertantly ... pulled the sender / reader apart. ... enough to read or should it ride on the glass scale? ...
    (rec.crafts.metalworking)