LEADTOOLS Raster Imaging C DLL Help > Function References > l_annsavemultioffset |
#include "l_bitmap.h"
L_LTANN_API L_INT L_AnnSaveMultiOffset(fd, nOffset, puSizeWritten, phObjects, nCount, uFormat, fSelected, pSaveOptions)
L_HFILE fd; |
/* windows file handle of the file to be saved */ |
L_SSIZE_T nOffset; |
/* where to embed the saved annotation file */ |
L_SIZE_T *puSizeWritten; |
/* address of the variable to be updated */ |
HANNOBJECT *phObjects; |
/* pointer to an array of annotation container handles */ |
L_INT nCount; |
/* number of objects in the phObjects array */ |
L_UINT uFormat; |
/* file format for saving annotation data */ |
L_BOOL fSelected; |
/* flag that indicates which objects to be saved */ |
pSAVEFILEOPTION pSaveOptions; |
/* pointer to optional extended save options */ |
Saves an array of annotation containers at a specified position in an existing file.
Parameter |
Description |
|
fd |
The Windows file handle of the file to save. |
|
nOffset |
The offset within the specified file to embed the saved annotation file. For example, if you specify 5, then 5 bytes of other data will precede the embedded file. |
|
puSizeWritten |
Address of a variable to be updated with the size of the embedded file. |
|
phObjects |
Pointer to an array of handles to annotation container objects. Each annotation container object can include multiple annotation objects. |
|
hObject |
Handle to the annotation object. |
|
nCount |
The number of objects in the phObjects array |
|
uFormat |
Format for saving annotation data. Possible values are: |
|
|
Value |
Meaning |
|
ANNFMT_XML |
[0x0005] Save as an XML text format. This is the only format supported for this call. All other values return ERROR_FEATURE_NOT_SUPPORTED. |
fSelected |
Flag that indicates which objects to save. Possible values are: |
|
|
Value |
Meaning |
|
TRUE |
Save all objects that have the selected property set to TRUE. For getting and setting the selected property, use the L_AnnGetSelected and L_AnnSetSelected functions. |
|
FALSE |
Save only the specified object. |
pSaveOptions |
Pointer to a SAVEFILEOPTION structure that contains optional extended save options. Pass NULL because this parameter is currently ignored. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function overwrites existing data at the specified location in the file. You can use this function to update an image that you loaded with the L_AnnLoadMultiOffset function. The offset is specified in bytes. You must open the file and get a Windows file handle before calling this function.
Before calling this function, you must declare a variable of data type L_UINT32. Then, pass the address of the variable in the puSizeWritten parameter. This function will update the variable with the size of the embedded file.
This function saves an entire array of annotation container objects with each page of the multi-page annotation file corresponding to one of the annotation containers. If pFile already exists, it will be overwritten. If phObjects contains many annotation containers, then this function will create the multi-page annotation file much faster than repeated calls to the L_AnnSave function. Note that this function only supports the ANNFMT_XML format. Passing any other format for uFormat will return an ERROR_FEATURE_NOT_SUPPORTED error.
Required DLLs and Libraries
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 creates an annotation container with two objects, saves ten copies of the container in a multipage annotation file at offset 30, and then reloads the ten containers from the file.
#ifndef MAX_ANN_CONTAINERS #define MAX_ANN_CONTAINERS (10) #endif L_VOID AnnSaveMultiOffsetExample(HWND hwnd, L_TCHAR *pszFileMultiOut) { HANNOBJECT hContainer = NULL; HANNOBJECT hRect = NULL; HANNOBJECT hEllipse = NULL; ANNRECT rc = {0,0, 600,600}; L_AnnCreateContainer(hwnd, &rc, TRUE, &hContainer); // Create a rectangle object ANNRECT rcRect = {20,20,120,120}; L_AnnCreate(ANNOBJECT_RECT, &hRect); L_AnnSetForeColor(hRect, RGB(255,0,0), 0); L_AnnSetRect(hRect, &rcRect); L_AnnSetVisible(hRect, TRUE, 0, NULL); L_AnnInsert(hContainer, hRect, FALSE); // Create an ellipse object ANNRECT rcEllipse = {120,120,220,220}; L_AnnCreate(ANNOBJECT_ELLIPSE, &hEllipse); L_AnnSetForeColor(hEllipse, RGB(0,0,255), 0); L_AnnSetRect(hEllipse, &rcEllipse); L_AnnSetVisible(hEllipse, TRUE, 0, NULL); L_AnnInsert(hContainer, hEllipse, FALSE); HANNOBJECT hObjects[MAX_ANN_CONTAINERS] = {0}; for (int i=0; i<MAX_ANN_CONTAINERS; i++) hObjects[i] = hContainer; // This saves a multipage annotation file -- there will be MAX_ANNCONTAINERS pages L_SIZE_T SizeWritten = 0; DWORD dwBytesWritten = 0; HANDLE hFileNew = CreateFile(pszFileMultiOut, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); // Write header information -- 29 characters and a terminator WriteFile(hFileNew, "This is a 29-character string", 30, &dwBytesWritten, NULL); L_AnnSaveMultiOffset((L_HFILE)hFileNew, 30, &SizeWritten, hObjects, MAX_ANN_CONTAINERS, ANNFMT_XML, FALSE, NULL); // Close the file CloseHandle(hFileNew); // Now load the multipage annotation file. Assume we do not know the number of pages in the file. // Call the function twice -- the first time to get the number of pages in the multi-page annotation file HANDLE hFileOffset = CreateFile(pszFileMultiOut, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); L_INT nItemsRead = 0; L_AnnLoadMultiOffset((L_HFILE)hFileOffset, 30, 0xFFFF, NULL, 0, &nItemsRead, NULL); if (nItemsRead != 0) { HANNOBJECT *phObjects = new HANNOBJECT[nItemsRead]; L_AnnLoadMultiOffset((L_HFILE)hFileOffset, 30, 0xFFFF, NULL, nItemsRead, &nItemsRead, NULL); delete phObjects; } // Cleanup CloseHandle(hFileOffset); L_AnnDestroy(hContainer, ANNFLAG_RECURSE); MessageBox(hwnd, TEXT("Finished"), TEXT(""), MB_OK); }