L_ReadFileExtensions

#include "l_bitmap.h"

L_INT EXT_FUNCTION L_ReadFileExtensions(pszFile, ppExtensionList, pLoadOptions)

L_TCHAR L_FAR * pszFile;

/* file name */

pEXTENSIONLIST L_FAR * ppExtensionList;

/* pointer to a pointer to a structure */

pLOADFILEOPTION pLoadOptions;

/* pointer to optional extended load options */

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

Parameter

Description

pszFile

Character string containing Exif file name.

ppExtensionList

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

pLoadOptions

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

Returns

>=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

LTFIL
Exif file format DLLs

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

Platforms

Windows 95 / 98 / Me, Windows 2000 / XP, Windows CE.

See Also

Functions:

L_LoadExtensionStamp, L_GetExtensionAudio, L_FreeExtensions, L_ReadFileStamp

Topics:

Raster Image Functions: Getting and Setting File Information

 

Exif File Extensions

 

Implementing Exif Features

Example

This example will show detailed information on the streams present in the Exif file.

#include <stdio.h>

static L_INT GetExifInfo(HWND hWnd, L_TCHAR L_FAR* pszName)
{
   pEXTENSIONLIST pExtensionList;

L_INT nRet;

L_CHAR s[300];

L_UINT u;

L_CHAR aName[100];

L_CHAR aCLSID[50];

FILE *fd;

L_TCHAR szMsg[80];

 

   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;
   }

   // use fopen so I can use fprintf

   #ifdef UNICODE
      fd = _wfopen(TEXT("c:\\temp\\1.txt"), TEXT("wt"));

   #else

      fd = fopen("c:\\temp\\1.txt", "wt");

   #endif

 

   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(aName, "ERROR decoding the Unicode string");
      }

      if(pExtensionList->aList[u].pClsid)
      {
         StringFromGUID2(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
         strcpy(aCLSID, "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);

   // run notepad to show this file
   sprintf(s, "notepad c:\\temp\\1.txt");
   WinExec(s, SW_SHOW);

   L_FreeExtensions(pExtensionList);
   return SUCCESS;
}