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
 Camera Raw, filetype & EIERawException

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
stuartclennett@gmail.com Posted - Nov 14 2016 : 14:42:56
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
3   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Mar 08 2017 : 19:56:37
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
stuartclennett@gmail.com Posted - Nov 15 2016 : 05:16:51
Hi Nigel,

Great - thanks for that.

Best wishes,
Stuart

Stuart Clennett
Delphi Berlin 10.1
xequte Posted - Nov 14 2016 : 14:50:40
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