LFile::ReadTags

#include "ltwrappr.h"

L_INT LFile::ReadTags(uFlags, puTagCount, ppTags, puDataSize, ppData, pLoadOptions)

Gets all the tags stored in a file.

Parameters

L_UINT uFlags

Flag that determines whether to read the tag overall data. You can combine values when appropriate by using a bitwise OR ( | ):

Flag Meaning
READFILEMETADATA_NOMEMORY [0x01] Do not read the tag overall data. If this flag is set, then puDataSize and ppData will not be used and the function will not read the tag overall data.

L_UINT * puTagCount

Address of the variable to be updated with the number of tags found in the file.

pLEADFILETAG * ppTags

Pointer to an array of pLEADFILETAG structures. Each element of the array contains data for one tag found in the file. The number of elements in ppTags is puTagCount. When this array is no longer needed pass it to the LFile::FreeTags function to free the allocated memory.

L_SIZE_T * puDataSize

Address of the variable to be updated with the size in bytes of the overall tags data.

L_UCHAR ** ppData

Address of the variable to be updated with a pointer to the overall tags data. The size of this pointer in bytes is puDataSize. Each LEADFILETAG item found contains an offset to where the data for this item is stored in ppData.

pLOADFILEOPTION pLoadOptions

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

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

You must free the data allocated with this function using the LFile::FreeTags function.

For general information about TIFF tags, refer to Implementing TIFF Comments and Tags.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT LFile__ReadFileTagsExample() 
{ 
   LFile LeadFile; 
   L_INT nRet; 
   L_UINT i = 0, uTagCount = 0, uCommentCount = 0, uGeoKeyCount = 0; 
   pLEADFILETAG pTags = NULL, pCurrentTag, pGeoKeys = NULL, pCurrentGeoKey; 
   L_SIZE_T uTagDataSize = 0, uCommentDataSize = 0, uGeoKeyDataSize = 0; 
   L_UCHAR *pTagData = NULL, *pCommentData = NULL, *pGeoKeyData = NULL; 
   L_CHAR *pszAscii = NULL; 
   pLEADFILECOMMENT pComments = NULL, pCurrentComment; 
 
   LeadFile.SetFileName(TEXT("C:\\LEADTOOLS21\\Resources\\Images\\image1.jpg")); 
 
   // read all the tags from the file 
   nRet = LeadFile.ReadTags(0, &uTagCount, &pTags, &uTagDataSize, &pTagData, NULL); 
 
   // Read all the comments in the file 
   if(nRet == SUCCESS) 
   { 
      // Yes, read all the comments from the file 
      nRet = LeadFile.ReadComments(0, &uCommentCount, &pComments, &uCommentDataSize, &pCommentData, NULL); 
   } 
 
   // Read all the geo keys in the file 
   if(nRet == SUCCESS) 
   { 
      // Yes, read all the geo keys from the file 
      nRet = LeadFile.ReadGeoKeys(0, &uGeoKeyCount, &pGeoKeys, &uGeoKeyDataSize, &pGeoKeyData, NULL); 
   } 
 
   if(nRet == SUCCESS) 
   { 
      if(uTagCount > 0) 
      { 
         // Show the tags 
         wprintf(L"Tags\n"); 
         for(i = 0; i < uTagCount; i++) 
         { 
            pCurrentTag = &pTags[i]; 
 
            // If this tag is of type ASCII, get its data 
            if(pCurrentTag->uType == TAG_ASCII) 
            { 
               pszAscii = (L_CHAR*)malloc(pCurrentTag->uDataSize + 1); 
               ZeroMemory(pszAscii, pCurrentTag->uDataSize + 1); 
               CopyMemory(pszAscii, pTagData + pCurrentTag->uDataOffset, pCurrentTag->uDataSize); 
            } 
            else 
            { 
               pszAscii = NULL; 
            } 
 
            printf("Id: 0x%X, data length: %u, data: %s\n", pCurrentTag->uTag, pCurrentTag->uDataSize, pszAscii != NULL ? pszAscii : "Binary data"); 
         } 
 
         LeadFile.FreeTags(uTagCount, pTags, uTagDataSize, pTagData); 
      } 
 
      if(uCommentCount > 0) 
      { 
         // Show the Comments 
         wprintf(L"Comments\n"); 
         for(i = 0; i < uCommentCount; i++) 
         { 
            pCurrentComment = &pComments[i]; 
 
            // If this comment is of type ASCII, get its data 
            printf("Id: 0x%X, data length: %u\n", pCurrentComment->uType, pCurrentComment->uDataSize); 
         } 
 
         LeadFile.FreeComments(uCommentCount, pComments, uCommentDataSize, pCommentData); 
      } 
 
      if(uGeoKeyCount > 0) 
      { 
         // Show the geo keys 
         wprintf(L"GeoKeys\n"); 
         for(i = 0; i < uGeoKeyCount; i++) 
         { 
            pCurrentGeoKey = &pGeoKeys[i]; 
 
            // If this geo key is of type ASCII, get its data 
            if(pCurrentGeoKey->uType == TAG_ASCII) 
            { 
               pszAscii = (L_CHAR*)malloc(pCurrentGeoKey->uDataSize + 1); 
               ZeroMemory(pszAscii, pCurrentGeoKey->uDataSize + 1); 
               CopyMemory(pszAscii, pGeoKeyData + pCurrentGeoKey->uDataOffset, pCurrentGeoKey->uDataSize); 
            } 
            else 
            { 
               pszAscii = NULL; 
            } 
 
            printf("Id: 0x%X, data length: %u, data: %s\n", pCurrentGeoKey->uTag, pCurrentGeoKey->uDataSize, pszAscii != NULL ? pszAscii : "Binary data"); 
         } 
 
         LeadFile.FreeTags(uGeoKeyCount, pGeoKeys, uGeoKeyDataSize, pGeoKeyData); 
      } 
   } 
 
   return SUCCESS; 
} 
Help Version 21.0.2021.3.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help