LAnnContainer::FileInfoOffset

#include "ltwrappr.h"

virtual L_INT LAnnContainer::FileInfoOffset(fd, pAnnFileInfo, uStructSize)

Loads information about the annotation file embedded in another file, into the specified ANNFILEINFO structure.

Parameters

L_HFILE fd

The Windows file handle of the file.

pANNFILEINFO pAnnFileInfo

Pointer to the ANNFILEINFO structure to be updated with the annotation file information.

L_UINT uStructSize

Size in bytes, of the structure pointed to by pAnnFileInfo, for versioning. Use sizeof(ANNFILEINFO).

Returns

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

Comments

This function can be used to get information about a LEAD annotation file that is embedded in another file.

To use this function, do the following:

  1. Open the annotation file to get a Windows file handle.
  2. Declare a variable with the datatype of ANNFILEINFO.
  3. Fill in the nSize and nOffset fields of the ANNFILEINFO variable. The field nSize should contain the size of the ANNFILEINFO structure in bytes. The nOffset field should contain the byte location of the first byte of the annotation file.
  4. Call the [LAnnContainer:FileInfoOffset function, passing the Windows file handle, and the address of the ANNFILEINFO variable as parameters.
  5. Get the image information from the fields described in ANNFILEINFO structure.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT LAnnContainer_FileInfoOffsetExample(LAnnContainer & AnnContainer, L_TCHAR * szFile, L_UINT uFormat) 
{ 
   L_INT nRet; 
   HANDLE  hFile; 
   SAVEFILEOPTION SaveFileOption; 
   ANNFILEINFO AnnFileInfo; 
   L_TCHAR szMessage[256]; 
   L_TCHAR * szFormat; 
   DWORD uOffset = 30; 
   DWORD wWrittenBytes; 
    
   hFile = CreateFile(szFile, GENERIC_ALL, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); 
   WriteFile(hFile, "This is a 29-character string", uOffset,&wWrittenBytes,NULL); 
 
   // Save the annotations as the first page of the file 
   nRet =(L_INT) AnnContainer.SaveOffset((L_HFILE)&hFile, uOffset, uFormat, FALSE); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   // Flip and then save as the second page 
   nRet = AnnContainer.Flip(NULL, ANNFLAG_RECURSE); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   SaveFileOption.uStructSize = sizeof(SAVEFILEOPTION); 
   SaveFileOption.Flags = ESO_INSERTPAGE; 
   SaveFileOption.PageNumber = 2; 
   nRet = (L_INT)AnnContainer.SaveOffset((L_HFILE)&hFile , uOffset, uFormat, FALSE, &SaveFileOption); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   // Rotate and then save as the third page 
   nRet = AnnContainer.Rotate(45.0, NULL, ANNFLAG_RECURSE); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   SaveFileOption.PageNumber = 3; 
   nRet = (L_INT)AnnContainer.SaveOffset((L_HFILE)&hFile, uOffset, uFormat, FALSE, &SaveFileOption); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   // Get information about the file 
   AnnFileInfo.uStructSize = sizeof(ANNFILEINFO); 
   AnnFileInfo.nOffset = uOffset; 
   nRet = AnnContainer.FileInfoOffset((L_HFILE)&hFile, &AnnFileInfo, sizeof(AnnFileInfo)); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   switch (AnnFileInfo.uFormat) 
   { 
      case ANNFMT_NATIVE: 
         szFormat = TEXT("ANNFMT_NATIVE"); 
      break; 
 
      case ANNFMT_WMF: 
         szFormat = TEXT("ANNFMT_WMF"); 
      break; 
 
      case ANNFMT_ENCODED: 
         szFormat = TEXT("ANNFMT_ENCODED"); 
      break; 
 
      default: 
         szFormat = TEXT("Unknown"); 
      break; 
   } 
 
   wsprintf(szMessage, TEXT("File Name: %s\nVersion: %d\nFormat: %s\nTotal Pages: %d"), szFile, AnnFileInfo.nVersion, szFormat, AnnFileInfo.nTotalPages); 
 
   MessageBox(NULL, szMessage, TEXT("Information"), MB_OK); 
 
   // Now, delete the second page 
   nRet = AnnContainer.DeletePageOffset((L_HFILE)&hFile, uOffset, 2); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   // Again, get information about the file 
   AnnFileInfo.uStructSize = sizeof(ANNFILEINFO); 
   AnnFileInfo.nOffset = uOffset; 
   nRet = AnnContainer.FileInfoOffset((L_HFILE)&hFile, &AnnFileInfo, sizeof(AnnFileInfo)); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   wsprintf(szMessage, TEXT("File Name: %s\nVersion: %d\nFormat: %s\nTotal Pages: %d"), szFile, AnnFileInfo.nVersion, szFormat, AnnFileInfo.nTotalPages); 
 
   MessageBox(NULL, szMessage, TEXT("Information"), MB_OK); 
 
   CloseHandle(hFile); 
 
   return SUCCESS; 
} 
Help Version 20.0.2020.4.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help