LFile::ReadFileExtensions
#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 For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Functions: |
LFile::LoadExtensionStamp, LFile::GetExtensionAudio, LFile::FreeExtensions, LFile::ReadStamp, Class Members |
Topics: |
Raster Image Functions: Getting and Setting File Information |
|
|
|
Example
#include <stdio.h>
L_VOID GetExifInfo(L_TCHAR * pszFile, L_CHAR * pszInfoFile)
{
LFile File;
pEXTENSIONLIST pExtensionList;
L_CHAR szBuffer[512];
L_CHAR szName[128];
L_CHAR szCLSID[64];
FILE * fd;
File.SetFileName(pszFile);
if (File.ReadFileExtensions(&pExtensionList) != SUCCESS)
{
MessageBox(NULL, TEXT("Error getting extensions!"),
TEXT("Getting Extensions"), MB_OK);
return;
}
// Open the info .txt file
fd = fopen(pszInfoFile, "wt");
if(!fd)
{
MessageBox(NULL, TEXT("Error opening info file!"),
TEXT("Getting Extensions"), MB_OK);
return;
}
// Do we have a stamp, audio, or both?
switch(pExtensionList->uFlags & (EXTENSION_STAMP | EXTENSION_AUDIO))
{
case 0:
strcpy(szBuffer, ""); break;
case EXTENSION_STAMP:
strcpy(szBuffer, ", EXTENSION_STAMP"); break;
case EXTENSION_AUDIO:
strcpy(szBuffer, ", EXTENSION_AUDIO"); break;
case EXTENSION_STAMP | EXTENSION_AUDIO:
strcpy(szBuffer, ", EXTENSION_STAMP | EXTENSION_AUDIO"); break;
}
fprintf(fd, "Extension count: %d%s\n",pExtensionList->uCount, szBuffer);
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(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(szCLSID, "NULL");
// Write information about stream 'u'
fprintf(fd, "[%d]: Name = %s, DataSize = %d, CLSID = %s\n", u,
szName, pExtensionList->aList[u].uDataSize, szCLSID);
}
fclose(fd);
// Run notepad to show the info file
sprintf(szBuffer, "notepad %s", pszInfoFile);
WinExec(szBuffer, SW_SHOW);
File.FreeExtensions(pExtensionList);
}