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
 check for valid file types?
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

fjrohlf

USA
16 Posts

Posted - Jun 30 2013 :  18:54:37  Show Profile  Reply
Is there a convenient function in ImageEn that will simply verify whether a user entered file name corresponds to a supported image file type for input or output?

Jim

w2m

USA
1990 Posts

Posted - Jun 30 2013 :  19:30:03  Show Profile  Reply
if hyieutils.IsKnownFormat(AFilename) then
  ShowMessage('ok, I can load it.');

For Opening and Saving add a TOpenPictureDialog or a TSavePictureDialog to the form then call:

procedure TForm1.FormCreate(Sender: TObject);
{ FormCreate. }
begin
  hyieutils.IERegisterFormats;
  OpenPictureDialog1.Filter := GraphicFilter(TGraphic);
  SavePictureDialog1.Filter := GraphicFilter(TGraphic);
end;
procedure TForm1.FormDestroy(Sender: TObject);
{ FormDestroy. }
begin
  hyieutils.IEUnRegisterFormats;
end;

The dialogs filter will include supported image formats.

Also by using ImageEn Helper functions you can create this:
function IsKnownOpenFormat(AFilename: string): boolean;
{ Return True if opening AFilename is supported by ImageEnIO, false if not. }
var
  iSupportedExtensions: string;
begin
   iSupportedExtensions := GetAllSupportedFileExtensions(True, False, False);
   result := IEFilenameInExtensions(AFilename, iSupportedExtensions);
end;

function IsKnownSaveFormat(AFilename: string): boolean;
{ Return True if saving AFilename is supported by ImageEnIO, false if not. }
var
  iSupportedExtensions: string;
begin
   iSupportedExtensions := GetAllSupportedFileExtensions(False, True, False);
   result := IEFilenameInExtensions(AFilename, iSupportedExtensions);
end;

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
Go to Top of Page

fjrohlf

USA
16 Posts

Posted - Jun 30 2013 :  20:14:05  Show Profile  Reply
Thanks!

Your IsKnownSaveFormat function is exactly what I need.

Jim
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: