#include "l_bitmap.h"
L_LTANN_API L_INT L_AnnLoadOffset(fd, nOffset, nLength, phObject, pLoadOptions)
L_HFILE fd; |
/* Windows file handle of the file to load */ |
L_SSIZE_T nOffset; |
/* position of the first byte to load */ |
L_SIZE_T nLength; |
/* number of bytes to read */ |
pHANNOBJECT phObject; |
/* address of the variable to be updated */ |
pLOADFILEOPTION pLoadOptions; |
/* pointer to optional extended load options */ |
Loads annotations from a position within a file. This enables you to load an annotation file that is embedded in another file.
Parameter |
Description |
fd |
The Windows file handle of the file to load. |
nOffset |
The position, from the beginning of the file, of the first byte to load. (The byte count starts at zero.) |
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. |
phObject |
Address of the variable to be updated with the handle to the container object of the loaded annotations. |
pLoadOptions |
Pointer to optional extended load options. Pass NULL to use the default load options. |
Returns
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
LTANN For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Win32, x64.
See Also
Example
This example loads an annotation file with a 30-byte offset. Refer to L_AnnSaveOffset to see how the test file is created.
#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName #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; }