#include "l_bitmap.h"
L_LTANN_API L_INT L_AnnSaveMemory(hObject, uFormat, fSelected, phMem, puMemSize, pSaveOptions)
Saves the specified annotations to a file in memory.
Handle to the root annotation object that includes all objects to save in the file. This typically is a container object.
Format for saving annotation data. Possible values are:
Value | Meaning |
---|---|
ANNFMT_EMF | [0x0006] Use the Windows EMF format. |
ANNFMT_ENCODED | [0x0004] Save as a binary format. NOTE: This format has been replaced by ANNFMT_XML, and is no longer supported. |
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_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_WMF | [0x0001] Use the Windows WMF format. |
ANNFMT_XML | [0x0005] Save as an XML text format. This is LEADs new text based format which is upward compatible. It should be used instead of ANNFMT_NATIVE. |
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. |
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.
Address of a variable to be updated with the size of the file.
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 multipage annotation file. Pass NULL to save a one page annotation file.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
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 L_AnnSave, L_AnnSaveOffset, and L_AnnSaveMemory.
For backward compatibility, this latest version of LEADTOOLS can read the discontinued formats (ANNFMT_NATIVE and ANNFMT_ENCODED) with the following functions:
The ANNFMT_XML format offers many advantages over the older annotation formats:
Save annotations in the WMF format only for use in another application. LEADTOOLS reads annotations only in the native format.
To retain scaling and positioning information, this function always saves the root container, along with the specified object or selected objects. Use the hObject
and fSelected
parameters as follows:
Both the ANNFMT_TIFFTAG and the ANNFMT_WANGTAG can be saved inside a TIFF file using L_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 L_ReadFileTag and see if ANNTAG_TYPE is present.
If uFormat
is ANNFMT_XML, 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 you save a memory handle to a tag in TIF or WANG format, using L_AnnSaveMemory, you must write the memory handle to the tag into a file using L_SetTag and L_SaveBitmapMemory before you can load it using the L_AnnLoadMemory function.
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 multipage annotation file of type ANNFMT_XML. Note that all the pages of an annotation multipage 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 multipage file:
To replace an existing page in an annotation multipage file:
To delete a page from an annotation multipage file, use L_AnnDeletePage, L_AnnDeletePageMemory, L_AnnDeletePageOffset.
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 L_AnnSaveMemory.
Required DLLs and Libraries
Win32, x64.
For another example, refer to L_AnnFileInfoMemory.
L_INT AnnSaveMemoryExample(HWND hWnd,HANNOBJECT hContainer)
{
HANNOBJECT TmpContainer; /* Temporary container for the annotations */
HGLOBAL hTag; /* Memory handle */
L_SIZE_T zMemSize; /* Size of the data in memory */
L_UCHAR* pData; /* Pointer to the data in memory */
L_INT nRet;
HDC hdc;
RECT rAnnBounds;
RECT rAnnBoundsName;
/* Load the initial annotations */
nRet = L_AnnLoad(MAKE_IMAGE_PATH(TEXT("cannon.ann")), &TmpContainer, NULL);
if(nRet != SUCCESS)
return nRet;
/* Save the annotations as a TIFF TAG in memory */
hTag = 0;
nRet = L_AnnSaveMemory(TmpContainer, ANNFMT_TIFFTAG, FALSE, &hTag, &zMemSize, NULL);
if(nRet != SUCCESS)
return nRet;
/* Get the pointer to the memory-resident tag */
pData = (L_UCHAR*) GlobalLock (hTag);
/* Set the tag so when the bitmap is saved as TIFF, the tag
is also saved */
nRet = L_SetTag(ANNTAG_TIFF, TAG_BYTE, (L_UINT) zMemSize, pData);
if(nRet != SUCCESS)
return nRet;
L_AnnDestroy(TmpContainer, ANNFLAG_RECURSE);
/* Load the new file from memory */
nRet = L_AnnLoadMemory(pData, zMemSize, &TmpContainer, NULL);
if (nRet == SUCCESS)
{
/* Insert the annotations into the main container, hContainer, so they will be active. */
nRet = L_AnnInsert(hContainer, TmpContainer, TRUE);
if(nRet != SUCCESS)
return nRet;
hdc = GetDC(hWnd);
nRet = L_AnnGetBoundingRect(hContainer, &rAnnBounds, &rAnnBoundsName);
if(nRet != SUCCESS)
return nRet;
nRet = L_AnnDraw(hdc, &rAnnBounds, hContainer);
if(nRet != SUCCESS)
return nRet;
ReleaseDC(hWnd, hdc);
}
else
return nRet;
L_AnnDestroy(TmpContainer, ANNFLAG_RECURSE);
/* Clean up */
GlobalUnlock (hTag);
GlobalFree (hTag);
return SUCCESS;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document