ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CanLoadImage
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PeterPanino

914 Posts

Posted - Aug 19 2024 :  14:36:30  Show Profile  Reply
Is this the most efficient and fastest way to determine if a file is an image file (that can be loaded in ImageEn)?

function CanLoadImage(const AFile: string): Boolean;
var
  ImageEnIO: TImageEnIO;
begin
  Result := True;
  ImageEnIO := TImageEnIO.Create(nil);
  try
    try
      ImageEnIO.LoadFromFileAuto(AFile);
    except
      on E: Exception do
        Result := False;
    end;
  finally
    ImageEnIO.Free;
  end;
end;

PeterPanino

914 Posts

Posted - Aug 19 2024 :  15:38:47  Show Profile  Reply
I now use iexBitmaps.IsKnownFormat, which is much faster.
Go to Top of Page

xequte

38458 Posts

Posted - Aug 19 2024 :  17:48:52  Show Profile  Reply
Yes, though note that IsKnownFormat only checks that the file extension is known:

https://www.imageen.com/help/IsKnownFormat.html

(so would fail for a file with no or an incorrect extension)

To check the actual file content is recognized (a bit slower), use:

https://www.imageen.com/help/FindFileFormat.html

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: