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
 Camera Raw, filetype & EIERawException
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

stuartclennett@gmail.com

United Kingdom
72 Posts

Posted - Nov 14 2016 :  14:42:56  Show Profile  Reply
Hi,

I'm intending on offering Raw (& DICOM) support as an add-on to my software.

When a user selects a CR2 (for instance) file (in a FolderMView) to preview (in an ImageEnView) before importing to the database, I'd like to detect that they're attempting to access an ioRAW file and if IELibAvailable = false, then pop up some kind of prompt for them to get the add-on.

Code I'm using at the moment to detect formats is:

TFileAddResult = (faOK, faNotSupported, faNeedsAddOn);
...
function AddFile(const aFilename : string) : TFileAddResult;
begin
  aIO := TImageEnIO.Create(nil);
  try
    try
      aIO.ParamsFromFile(aFilename); 
      if aIO.Params.FileType = ioUnknown then
        result := faNotSupported
      else
      if aIO.Params.FileType in [ioRAW, ioBMPRAW, ioDICOM] then
        result := faNeedsAddOn
      else
      if ImageEnMView.MIO.LoadFromFileAuto(aFilename) then
        result := faOK;
    except
      on EIERawException do
        result := faNeedsAddOn;

      on Exception do
        result := faNotSupported;
    end;
  finally
    aIO.Free;
  end;
end;


Problem is, the line in bold raises an EIERawException which is handled internally but it leaves the aIO.Params.FileType as ioUnknown - so I cannot detect if the user has tried to access a genuine Raw file versus just some random unsupported file...?

What's the best method for detecting a file type from a filename when IELIB isn't available ?

Cheers




Stuart Clennett
Delphi Berlin 10.1

xequte

38198 Posts

Posted - Nov 14 2016 :  14:50:40  Show Profile  Reply
Hi Stuart

Yes, you make a valid point. I will add an event that allows custom handling of missing DLL issues such as this.

In the meantime, you might want to check using the file extension:

  if IEFileExtInExtensions( ex, Camera_Raw_File_Extensions ) then
    result := ioRAW




Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

stuartclennett@gmail.com

United Kingdom
72 Posts

Posted - Nov 15 2016 :  05:16:51  Show Profile  Reply
Hi Nigel,

Great - thanks for that.

Best wishes,
Stuart

Stuart Clennett
Delphi Berlin 10.1
Go to Top of Page

xequte

38198 Posts

Posted - Mar 08 2017 :  19:56:37  Show Profile  Reply
Hi Stuart

Looking at the code, I decided that raising the exception would handle the issue adequately rather than adding an event property. IOW, you can handle it with the code in your first post.



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