Re: Once and for all! Fastest way to load large jpeg
- From: erewhon@xxxxxxxxxx (J French)
- Date: Sun, 10 Dec 2006 07:26:34 GMT
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
.
- Follow-Ups:
- References:
- Once and for all! Fastest way to load large jpeg
- From: jimbo
- Once and for all! Fastest way to load large jpeg
- Prev by Date: Re: Once and for all! Fastest way to load large jpeg
- Next by Date: Re: Once and for all! Fastest way to load large jpeg
- Previous by thread: Re: Once and for all! Fastest way to load large jpeg
- Next by thread: Re: Once and for all! Fastest way to load large jpeg
- Index(es):
Relevant Pages
|