I have to deal with pretty large TIFF files (some 100 MB). This is my code to load an image:
Is this the fastest way to load an image? I observe that IrfanView is able to open the same images considerably faster. In my program I used the high-level VCL interface, is it faster to use the low-level routines instead?
A related question concerns memory usage. What is the best practice to avoid multiple memory allocations and copy operations?
Code Select
type
TMainForm = class(TForm)
...
private
FImg : TSingleImage;
{$IFDEF USE_GR32}
Image32 : TImage32;
{$ENDIF}
procedure LoadFile(AFileName:string);
...
end;
procedure TMainForm.LoadFile(AFileName:string);
var
T : int64;
imgbitmap : TImagingBitmap;
success : boolean;
begin
success := false;
T := ImagingUtility.GetTimeMicroseconds;
FreeAndNil(FImg);
Screen.Cursor := crHourglass;
try
FImg := TSingleImage.CreateFromFile(AFileName);
if FImg <> nil then begin
imgbitmap := TImagingBitmap.Create;
try
imgbitmap.Assign(FImg);
{$IFDEF USE_GR32}
Image32.Bitmap.Assign(imgbitmap);
{$ELSE}
Image.Picture.Assign(imgbitmap);
{$ENDIF}
success := true;
finally
imgbitmap.Free;
end;
end;
...
finally
Screen.Cursor := crDefault;
end;
end;
Is this the fastest way to load an image? I observe that IrfanView is able to open the same images considerably faster. In my program I used the high-level VCL interface, is it faster to use the low-level routines instead?
A related question concerns memory usage. What is the best practice to avoid multiple memory allocations and copy operations?