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



On 9 Dec 2006 22:51:07 -0800, jimbo@xxxxxxxxxx wrote:

<snip>

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.


There sure is, look at FileSize( FileName )

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;

The file size of a JPEG is of no relevance to the pixel size of the
image it contains, as the internal bitmap in the file may or may not
be compressed.
An uncompressed small image may take more disk space than a large
image that uses 100% compression.

I would scratch using the File size and use the Height and Width
properties exposed by TJpegImage


.



Relevant Pages

  • 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)
  • 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: Accessing tick counter without api
    ... >> just access the tick count via memory, ... Scale & offset to ticks if needed. ...
    (comp.lang.asm.x86)