Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.24
LEADTOOLS Raster imaging C++ Class library help

LFile::ReadFileExtensions

Show in webframe

#include "ltwrappr.h"

virtual L_INT LFile::ReadFileExtensions(ppExtensionList, pLoadOptions=NULL)

pEXTENSIONLIST * ppExtensionList;

/* pointer to a pointer to a structure */

pLOADFILEOPTION pLoadOptions;

/* pointer to optional extended load options */

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

Parameter

Description

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 LFile::LoadExtensionStampfunction can be used to load a stamp from the extension and LFile::GetExtensionAudio can be used to get embedded audio data.

When the memory allocated by this function is no longer needed, call LFile::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

Win32, x64.

See Also

Functions:

LFile::LoadExtensionStamp, LFile::GetExtensionAudio, LFile::FreeExtensions, LFile::ReadStamp, Class Members

Topics:

Raster Image Functions: Getting and Setting File Information

 

Exif File Extensions

 

Implementing Exif Features

Example

#include <stdio.h>
L_INT LFile__ReadFileExtensionsExample(L_TCHAR * pszFile, L_TCHAR * pszInfoFile)
{
   L_INT nRet;
   LFile File;
   pEXTENSIONLIST pExtensionList;
   L_TCHAR szBuffer[512];
   L_TCHAR szText[1024];
   L_CHAR szName[128];
   L_CHAR szCLSID[64];
   HANDLE fd;
   DWORD dwSizeWrite;
   File.SetFileName(pszFile);
   nRet = File.ReadFileExtensions(&pExtensionList);
   if(nRet != SUCCESS)
   {
      MessageBox(NULL, TEXT("Error getting extensions!"),
                  TEXT("Getting Extensions"), MB_OK);
      return nRet;
   }
   // Open the info .txt file
   fd = CreateFile(pszInfoFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
   if(!fd)
   {
      MessageBox(NULL, TEXT("Error opening info file!"),
                        TEXT("Getting Extensions"), MB_OK);
      return FAILURE;
   }
   // Do we have a stamp, audio, or both?
   switch(pExtensionList->uFlags & (EXTENSION_STAMP | EXTENSION_AUDIO))
   {
   case 0:
      lstrcpy(szBuffer, TEXT("")); break;
   case EXTENSION_STAMP:
      lstrcpy(szBuffer, TEXT(", EXTENSION_STAMP")); break;
   case EXTENSION_AUDIO:
      lstrcpy(szBuffer, TEXT(", EXTENSION_AUDIO")); break;
   case EXTENSION_STAMP | EXTENSION_AUDIO:
      lstrcpy(szBuffer, TEXT(", EXTENSION_STAMP | EXTENSION_AUDIO")); break;
   }
   wsprintf(szText, TEXT("Extension count: %d%s\n"), pExtensionList->uCount, szBuffer);
   WriteFile(fd, szText, 1024, &dwSizeWrite, NULL); 
   for (L_UINT 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
              szName,           // Buffer for new string
              sizeof(szName),   // Size of buffer
              NULL,             // Default for unmappable chars
              NULL))            // Sset when default char used
      {
         strcpy_s(szName, "ERROR decoding the Unicode string");
      }
      if (pExtensionList->aList[u].pClsid)
      {
         StringFromGUID2((REFGUID) pExtensionList->aList[u].pClsid,
                         (LPWSTR) szBuffer, sizeof(szBuffer));
         WideCharToMultiByte(CP_ACP,   // Code page
                              0,                   // Performance and mapping flags
                              (LPWSTR) szBuffer,   // Wide-character string
                              -1,                  // Number of chars in string
                              szCLSID,             // Buffer for new string
                              sizeof(szCLSID),     // Size of buffer
                              NULL,                // Default for unmappable chars
                              NULL);               // Set when default char used
      }
      else
         strcpy_s(szCLSID, "NULL");
      // Write information about stream 'u'
      wsprintf(szText, TEXT("[%d]: Name = %s, DataSize = %d, CLSID = %s\n"), u, szName, pExtensionList->aList[u].uDataSize, szCLSID);
      WriteFile(fd, szText, 1024, &dwSizeWrite, NULL); 
   }
   CloseHandle(fd);
   // Run notepad to show the info file
   wsprintf(szBuffer, TEXT("notepad %s"), pszInfoFile);
   WinExec((LPCSTR)szBuffer, SW_SHOW);
   nRet = File.FreeExtensions(pExtensionList);
   if(nRet != SUCCESS)
      return nRet;
   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.