L_AnnLoadOffset

#include "l_bitmap.h"

L_LTANN_API L_INT L_AnnLoadOffset(fd, nOffset, nLength, phObject, pLoadOptions)

Loads annotations from a position within a file. This enables you to load an annotation file that is embedded in another file.

Parameters

L_HFILE fd

The Windows file handle of the file to load.

L_SSIZE_T nOffset

The position, from the beginning of the file, of the first byte to load. (The byte count starts at zero.)

L_SIZE_T nLength

The number of bytes of annotation data to read from the file. If you saved the offset using L_AnnSaveOffset, the variable pointed to by puSizeWritten in that function contains the length of data saved. If you do not know the length of the data, pass 0xFFFFFFFF for this parameter.

pHANNOBJECT phObject

Address of the variable to be updated with the handle to the container object of the loaded annotations.

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

Before calling this function, you must declare a variable of data type HANNOBJECT. Then, pass the address of the variable in the phObject parameter. This function will update the variable with the handle to the container object of the loaded annotations.

For more information about loading and pasting automated annotations, refer to Loading and Pasting Automated Annotations.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example loads an annotation file with a 30-byte offset. For how the test file is created, refer to L_AnnSaveOffset.

#include <Tchar.h> 
L_INT AnnLoadOffsetExample(HWND       hWnd, 
                                          HANNOBJECT hContainer)/* Container annotation object */ 
{ 
   HANNOBJECT  TmpContainer; 
   HANDLE      OffsetFile = NULL; /* File handle */ 
   HANDLE      hFile = NULL;      /* File handle */ 
   L_INT       nRet; 
   HDC         hdc; 
   RECT        rAnnBounds; 
   RECT        rAnnBoundsName; 
   DWORD dwBytesWritten = 0; 
   L_SIZE_T SizeWritten = 0;  
 
   // Create a file 
   hFile = CreateFile(MAKE_IMAGE_PATH(TEXT("TEST.ANN")), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); 
 
   // Write header information -- 29 characters and a terminator 
   //_write(NewFile, "This is a 29-character string", 30); 
   WriteFile(hFile, "This is a 29-character string", 30, &dwBytesWritten, NULL); 
 
   // Save the file with an offset 
   nRet = L_AnnSaveOffset( (L_HFILE)hFile, 30, &SizeWritten, hContainer, ANNFMT_XML, FALSE, NULL); 
   if (nRet == SUCCESS) 
      MessageBox(NULL, TEXT("File saved with offset"), TEXT("Notice"), MB_OK); 
   else 
      return nRet; 
 
   // Close the file 
   CloseHandle(hFile); 
 
   /* Open the file and get the file handle */ 
   OffsetFile = CreateFile(MAKE_IMAGE_PATH(TEXT("TEST.ANN")), GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); 
 
   /* Load the file with a 30-byte offset */ 
   nRet = L_AnnLoadOffset((L_HFILE) OffsetFile, 30, 0xFFFF, &TmpContainer, NULL); 
   /* if successfully loaded, view them */ 
   if (nRet == SUCCESS) 
   { 
      L_AnnInsert(hContainer, TmpContainer, TRUE); 
      hdc = GetDC(hWnd); 
      L_AnnGetBoundingRect(hContainer, &rAnnBounds, &rAnnBoundsName); 
      L_AnnDraw(hdc, &rAnnBounds, hContainer); 
   } 
   else 
      return nRet; 
   /* Close the file */ 
   CloseHandle(OffsetFile); 
   return SUCCESS; 
} 

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

LEADTOOLS Raster Imaging C API Help