LAnnContainer::SaveMemory
#include "ltwrappr.h"
virtual L_INT LAnnContainer::SaveMemory(uFormat, bSelected, phMem, puMemSize, pSaveOptions=NULL)
L_UINT uFormat; |
/* file format for saving annotation data */ |
L_BOOL bSelected; |
/* flag that indicates which objects to save */ |
HGLOBAL * phMem; |
/* address of a variable to be updated with the memory handle */ |
L_SIZE_T * puMemSize; |
/* address of a variable to be updated with the size of the file */ |
pSAVEFILEOPTION pSaveOptions; |
/* pointer to optional extended save options */ |
Saves the specified annotations to a file in memory.
Parameter |
Description |
|
uFormat |
Format for saving annotation data. Possible values are: |
|
|
Value |
Meaning |
|
ANNFMT_NATIVE |
[0x0000] Use LEAD's own format for annotations. NOTE: This format has been replaced by ANNFMT_XML, and is no longer supported. |
|
ANNFMT_WMF |
[0x0001] Save the file in the Windows WMF format. |
|
ANNFMT_TIFFTAG |
[0x0002] Save all annotation properties, including those not supported by the Wang specification as an ANNTAG_TIFF tag. |
|
ANNFMT_WANGTAG |
[0x0003] Save only the annotation properties supported by the Wang specification as an ANNTAG_TIFF tag. |
|
ANNFMT_ENCODED |
[0x0004] Save as a binary format. NOTE: This format has been replaced by ANNFMT_XML, and is no longer supported. |
|
ANNFMT_XML |
[0x0005] Save the file in an XML text format. This is LEADTOOLS new text-based format which is upward-compatible. It should be used instead of ANNFMT_NATIVE. |
bSelected |
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 LAnnotation::IsSelected and LAnnotation::SetSelected functions. |
|
FALSE |
Save only the specified object. |
phMem |
Address of a variable to be updated with the memory handle. This function uses the handle to allocate the memory. It unlocks the memory upon completion of the save. |
|
puMemSize |
Address of a variable to be updated with the size of the file. |
|
pSaveOptions |
Pointer to a SAVEFILEOPTION structure that contains optional extended save options. This information is used to add annotation pages or replace annotation pages in a multi-page annotation file. Pass NULL to save a one-page annotation file. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
In version 15.0, the text based format ANNFMT_XML is replacing ANNFMT_NATIVE and ANNFMT_ENCODED. Note that ANNFMT_NATIVE and ANNFMT_ENCODED are no longer supported as options with LAnnContainer::Save, LAnnContainer::SaveOffset, and LAnnContainer::SaveMemory.
For backward compatibility, this latest version of LEADTOOLS can read the discontinued formats (ANNFMT_NATIVE and ANNFMT_ENCODED) with the following functions:
LAnnContainer::DeletePageOffset
LAnnContainer::DeletePageMemory
The ANNFMT_XML format offers many advantages over the older annotation formats:
It is both forward- and backward-compatible.
It is human readable.
It can be easily modified using a standard text editor (i.e. notepad.exe).
It can be easily parsed using any standard XML parser.
It can be used with any of the growing number of utilities that work with XML.
Save annotations in the WMF format only for use in another application.
To retain scaling and positioning information, this function always saves the root container, along with the specified object or selected objects. Use the bSelected parameter as follows:
To save only selected objects in a container, set bSelected to TRUE.
To save all objects in a container, set bSelected to FALSE.
Both the ANNFMT_TIFFTAG and the ANNFMT_WANGTAG can be saved inside a TIFF file using LFileSettings::SetTag with uTag set to ANNTAG_TIFF and uType set to TAG_BYTE.
To detect whether a TIF file has annotation information, you should call LFileSettings::GetTag and see if ANNTAG_TYPE is present.
If uFormat is ANNFMT_NATIVE, phMem is updated with a memory handle to the annotation file in memory.
If uFormat is ANNFMT_TIFFTAG or ANNFMT_WANGTAG, phMem is updated with a memory handle to the tag.
If this function returns SUCCESS and phMem is updated with NULL, there are no annotations objects to save.
The information in the SAVEFILEOPTION structure can be used to add new pages or replace existing pages in a multi-page annotation file of type ANNFMT_XML. Note that all the pages of an annotation multi-page file must be all of type ANNFMT_XML. An annotation file cannot contain pages of different format types.
To insert new pages to an annotation multi-page file:
1. |
Declare a variable of type SAVEFILEOPTION. |
2. |
Set the uFlags field of the SAVEFILEOPTION structure to ESO_INSERTPAGE. |
3. |
Set the PageNumber field of the SAVEFILEOPTION structure to the location for insertion. The new page will be inserted in front of the page specified in the PageNumber field. |
To replace an existing page in an annotation multi-page file:
1. |
Declare a variable of type SAVEFILEOPTION. |
2. |
Set the uFlags field of the SAVEFILEOPTION structure to ESO_REPLACEPAGE. |
3. |
Set the PageNumber field of the SAVEFILEOPTION structure to the page to replace. |
To delete a page from an annotation multi-page file, use LAnnContainer::DeletePage, LAnnContainer::DeletePageMemory, or LAnnContainer::DeletePageOffset.
When adding or replacing an annotation page in an existing memory file, pass the address of a valid HGLOBAL hMem (non zero). When creating a new memory file, declare a variable of type HGLOBAL and set it to zero before passing the address to LAnnContainer::SaveMemory.
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
For an example, refer to LAnnContainer::LoadMemory.