L_AnnFileInfoOffset

Summary

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

Syntax

#include "l_bitmap.h"

L_LTANN_API L_INT L_AnnFileInfoOffset(fd, pAnnFileInfo, uStructSize)

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

The following example saves an annotation container as the first page of a multi-page annotation file.
The format is specified by the 'uFormat' parameter.
The file is saved, starting 30 bytes into the file.
The container is flipped, and saved as the second page.
The container is rotated, and saved as the third page.
Information is displayed about the annotation file.
The second page is deleted, and information is again displayed about the annotation file.

L_INT AnnFileInfoOffsetExample(L_TCHAR * pszFileName, L_UINT32 uFormat, HANNOBJECT hContainer) 
{ 
   L_HANDLE       hFile = NULL; 
   L_INT          nRet; 
   SAVEFILEOPTION SaveFileOption; 
   ANNFILEINFO    AnnFileInfo; 
   L_TCHAR        szMsg[200]; 
   L_TCHAR*       pszFormat; 
   L_SIZE_T       zSizeWritten; 
   L_UINT32       uOffset = 30; 
   DWORD          dwSizeWrite; 
 
   hFile = CreateFile(pszFileName, GENERIC_WRITE | GENERIC_READ, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); 
 
   WriteFile(hFile, "This is a 29-character string", uOffset, &dwSizeWrite, NULL); 
 
   //Save as the first page of the annotation file 
   nRet = L_AnnSaveOffset((L_HFILE)hFile, uOffset, &zSizeWritten, hContainer, uFormat, L_FALSE, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   //Flip the container, and save as the second page (insert before page 2) 
   SaveFileOption.uStructSize = sizeof(SAVEFILEOPTION); 
   SaveFileOption.Flags = ESO_INSERTPAGE; 
   SaveFileOption.PageNumber = 2; 
 
   nRet = L_AnnFlip(hContainer, NULL, ANNFLAG_RECURSE); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   nRet = L_AnnSaveOffset((L_HFILE)hFile, uOffset, &zSizeWritten, hContainer, uFormat, L_FALSE, &SaveFileOption); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   //Rotate the container, and save as the third page 
   nRet = L_AnnRotate(hContainer, 45.0, NULL, ANNFLAG_RECURSE); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   SaveFileOption.PageNumber = 3; 
   nRet = L_AnnSaveOffset((L_HFILE)hFile, uOffset, &zSizeWritten, hContainer, uFormat, L_FALSE, &SaveFileOption); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   //Verify contents of file 
   AnnFileInfo.uStructSize = sizeof(ANNFILEINFO); 
   AnnFileInfo.nOffset = uOffset; 
   AnnFileInfo.nReserved = 0; 
   nRet = L_AnnFileInfoOffset((L_HFILE)hFile, &AnnFileInfo, sizeof(ANNFILEINFO)); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   switch (AnnFileInfo.uFormat) 
   { 
   case ANNFMT_NATIVE: 
      pszFormat = TEXT("ANNFMT_NATIVE"); 
      break; 
 
   case ANNFMT_WMF: 
      pszFormat = TEXT("ANNFMT_WMF"); 
      break; 
 
   case ANNFMT_ENCODED: 
      pszFormat = TEXT("ANNFMT_ENCODED"); 
      break; 
 
   case ANNFMT_XML: 
      pszFormat = TEXT("ANNFMT_XML"); 
      break; 
 
   default: 
      pszFormat = TEXT("Unknown"); 
      break; 
   } 
 
   wsprintf(szMsg, 
      TEXT("Information: File[%s]\nVersion[%d]\nFormat[%s]\nTotal Pages[%d]\n"), 
      pszFileName, 
      AnnFileInfo.nVersion, 
      pszFormat, 
      AnnFileInfo.nTotalPages); 
 
   _tprintf(_T("%s"), szMsg); 
 
   //Now delete the second page, and display information 
   nRet = L_AnnDeletePageOffset((L_HFILE)hFile, uOffset, 2); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   AnnFileInfo.uStructSize = sizeof(ANNFILEINFO); 
   AnnFileInfo.nReserved = 0; 
   nRet = L_AnnFileInfoOffset((L_HFILE)hFile, &AnnFileInfo, sizeof(ANNFILEINFO)); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   wsprintf(szMsg, 
      TEXT("Information: File[%s]\nVersion[%d]\nFormat[%s]\nTotal Pages[%d]\n"), 
      pszFileName, 
      AnnFileInfo.nVersion, 
      pszFormat, 
      AnnFileInfo.nTotalPages); 
 
   _tprintf(_T("%s"), szMsg); 
 
   CloseHandle(hFile); 
 
   return SUCCESS; 
} 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.