L_ReadFileExtensions

#include "l_bitmap.h"

L_LTFIL_API L_INT L_ReadFileExtensions(pszFile, ppExtensionList, pLoadOptions)

Loads extensions from the specified Exif file. Please note that not all Exif files have extensions.

Parameters

L_TCHAR* pszFile

Character string containing Exif file name.

pEXTENSIONLIST* ppExtensionList

Pointer to a pointer to an EXTENSIONLIST structure to be updated with the extensions read from the specified Exif file.

pLOADFILEOPTION pLoadOptions

Pointer to optional extended load options. Pass NULL to use the default load options.

Returns

Value Meaning
>=0 Length of the comment field.
< 0 An error occurred. Refer to Return Codes.

Comments

Currently, this function works only with Exif files. Exif files can contain extra data stored as "FlashPix extensions". This function can be used to access this extra data. LEADTOOLS refers to this extra data as "extensions".

The L_LoadExtensionStamp function can be used to load a stamp from the extension and L_GetExtensionAudio can be used to get embedded audio data.

When the memory allocated by this function is no longer needed, call L_FreeExtensions to free the memory.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

L_INT ReadFileExtensionsExample(HWND hWnd, L_TCHAR * pszName) 
{ 
   pEXTENSIONLIST pExtensionList; 
   L_INT nRet; 
   L_UINT u; 
   L_CHAR aName[100]; 
   L_TCHAR aCLSID[50]; 
   FILE* fd; 
   L_TCHAR szMsg[80]; 
   L_TCHAR s[800]; 
 
   nRet = L_ReadFileExtensions(pszName, &pExtensionList, NULL); 
   if(nRet != SUCCESS) 
   { 
      wsprintf(szMsg, TEXT("Error %d getting extensions!"), nRet); 
      MessageBox(hWnd, szMsg, TEXT("ERROR"), MB_OK); 
      return nRet; 
   } 
 
   _tfopen_s(&fd, MAKE_IMAGE_PATH(TEXT("1.txt")), TEXT("w+")); 
   if(!fd) 
   { 
      wsprintf(szMsg, TEXT("Error %d getting extensions!"), nRet); 
      MessageBox(hWnd, szMsg, TEXT("ERROR"), MB_OK); 
      return nRet; 
   } 
 
   // display whether we have a stamp, audio or both 
   switch(pExtensionList->uFlags & (EXTENSION_STAMP|EXTENSION_AUDIO)) 
   { 
   case 0: 
      lstrcpy(s, TEXT("")); break; 
   case EXTENSION_STAMP: 
      lstrcpy(s, TEXT(", EXTENSION_STAMP")); break; 
   case EXTENSION_AUDIO: 
      lstrcpy(s, TEXT(", EXTENSION_AUDIO")); break; 
   case EXTENSION_STAMP|EXTENSION_AUDIO: 
      lstrcpy(s, TEXT(", EXTENSION_STAMP|EXTENSION_AUDIO")); break; 
   } 
   fprintf(fd, "Extension count: %d%s\n", pExtensionList->uCount, s); 
 
   for(u = 0; u < pExtensionList->uCount; u++) 
   { 
      // translate the Unicode string to multibyte 
      if( !WideCharToMultiByte(CP_ACP,       // code page 
                        0,                   // performance and mapping flags 
                        pExtensionList->aList[u].pName,    // wide-character string 
                        -1,                  // number of chars in string 
                        aName,               // buffer for new string 
                        sizeof(aName),       // size of buffer 
                        NULL,                // default for unmappable chars 
                        NULL))               // set when default char used 
      { 
         strcpy_s(aName, "ERROR decoding the Unicode string"); 
      } 
 
      if(pExtensionList->aList[u].pClsid) 
      { 
          
         StringFromGUID2((GUID &)pExtensionList->aList[u].pClsid, (LPWSTR)s, sizeof(s)); 
         WideCharToMultiByte(CP_ACP,         // code page 
                        0,                   // performance and mapping flags 
                        (LPWSTR)s,           // wide-character string 
                        -1,                  // number of chars in string 
                        (LPSTR)aCLSID,              // buffer for new string 
                        sizeof(aCLSID),      // size of buffer 
                        NULL,                // default for unmappable chars 
                        NULL);               // set when default char used 
      } 
      else 
         lstrcpy(aCLSID, TEXT("NULL")); 
 
      // write information about stream 'u' 
      fprintf(fd, "[%d]: Name=%s, DataSize=%d, CLSID=%s\n", u, aName, pExtensionList->aList[u].uDataSize, aCLSID); 
   } 
   fclose(fd); 
 
   ShellExecute(hWnd, TEXT("open"),MAKE_IMAGE_PATH(TEXT("1.txt")), NULL, NULL, SW_SHOWNORMAL); 
 
   L_FreeExtensions(pExtensionList); 
   return SUCCESS; 
} 
Help Version 20.0.2020.4.3
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help