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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 CanLoadImage

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Aug 19 2024 : 14:36:30
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;
2   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Aug 19 2024 : 17:48:52
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
PeterPanino Posted - Aug 19 2024 : 15:38:47
I now use iexBitmaps.IsKnownFormat, which is much faster.