Re: Once and for all! Fastest way to load large jpeg




Nicholas Sherlock wrote:
jimbo@xxxxxxxxxx wrote:
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.

You're already taking advantage of the Jpeg scaling to reduce the amount
of data loaded. Try this, there should be less shuffling around:

procedure MyPicLoader(Sender: TObject);
Var
Offset, Size: Integer;
Pic: TPicture;
F: file of byte;
Begin
Offset := (Sender as TComponent).Tag;
// get size of file. I assume there's a better/faster way.
AssignFile(f, IncludeTrailingBackSlash(filelistbox1.Directory) +
filelistbox1.Items[offset]);
Reset(f);
Size := Round(filesize(f)/1000);
closefile(f);

BigPic.Picture.LoadFromFile(IncludeTrailingBackSlash(filelistbox1.Directory
) + filelistbox1.Items[Offset]);

with TJpegImage(BigPic.Picture.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;
End;
End;

Cheers,
Nicholas Sherlock

Nicolas thanks for the IncludeTrailingBackslash. (Delphi newbie). Does
the jpeg.scale need to be set before the call to jpeg.loadfromfile? In
my search for an answer I recall this being a point of debate but
haven't played with it. It would seem logical. Does setting the scale
after loading cause a re-read of every so many lines? How do the two
work together? Also I saw a reference to the possibility of multiple
scaling possibly using two jpeg objects but couldn't understand it and
lost the reference in the myriad. BTW I recall landing on your site in
my travels. Any help or insight will be appreciated. Thanks again.
Jim
--
http://www.sherlocksoftware.org

.



Relevant Pages

  • 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. ... 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: Freesat evaluation
    ... invent 'fixes' for when the dish has no scale, but BTAIM, the method ... is explained in more detail here, under "There Is No Scale On The ... However #1, for an offset dish, you need to know the offset to use ... the pivot bolts and the lock up bolt is at the 45 deg mark.....this equates ...
    (uk.tech.digital-tv)
  • Re: Freesat evaluation
    ... invent 'fixes' for when the dish has no scale, but BTAIM, the method ... is explained in more detail here, under "There Is No Scale On The ... However #1, for an offset dish, you need to know the offset to use ... the pivot bolts and the lock up bolt is at the 45 deg mark.....this ...
    (uk.tech.digital-tv)
  • Re: Freesat evaluation
    ... invent 'fixes' for when the dish has no scale, but BTAIM, the method ... is explained in more detail here, under "There Is No Scale On The ... However #1, for an offset dish, you need to know the offset to use ... the pivot bolts and the lock up bolt is at the 45 deg mark.....this equates ...
    (uk.tech.digital-tv)