L_AnnGetUserData

#include "l_bitmap.h"

L_LTANN_API L_INT L_AnnGetUserData(hObject, pUserData, puUserDataSize)

HANNOBJECT hObject;

handle to the annotation object

L_UCHAR *pUserData;

address of binary data to write

L_UINT *puUserDataSize;

address of variable to updated with length of user data

Gets the user-defined data of one or more annotation objects.

Parameter

Description

hObject

Handle to the annotation object.

pUserData

Address that binary data is read into. Can be NULL.

puUserDataSize

Address of variable to be updated with the length (in bytes) of the user data

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

Use this function to get the associated user-defined data of an annotation object.

When getting the user-defined data, call this function twice: one time with pUserData set to NULL to get the length of the data, and another time to get the actual data.

      HANNOBJECT hObject;   
      L_UCHAR *pUserData;   
      L_UINT uUserDataSize;   
      // Assume hObject is a valid annotation object   
      L_AnnGetUserData(hObject, NULL, &uUserDataSize);   
      pUserData = (L_UCHAR *)malloc(uUserDataSize);   
      L_AnnGetUserData(hObject, pUserData, &uUserDataSize); 

User data can be binary or text data, and can be any length. When the annotion object is copied, and the user data is also copied. When saving the annotation (L_AnnSave, L_AnnSaveMemory, L_AnnSaveOffset), the user data is saved.

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.

Platforms

Win32, x64.

See Also

Functions:

L_AnnSetAutoCursor, L_AnnGetAutoCursor, L_AnnSetUserData, L_AnnSetAutoSnapCursor, L_AnnGetAutoSnapCursor

Topics:

Annotation Objects - Automated Features

 

Implementing an Automated Annotation Program

 

Obtaining Annotation Object Information

Example

This sample loads/saves the contents of a BITMAPHANDLE from/to user data of an annotation object Call the sample once with bSave set to TRUE, then call it again with bSave set to FALSE to load the saved user data as a BITMAPHANDLE hObject -- the annotation object pBitmap -- the bitmap that is loaded/saved bLoad -- TRUE means load from the annotation object, FALSE means save to the annotation object

L_INT AnnGetUserDataExample(HANNOBJECT      hObject, 
pBITMAPHANDLE   pBitmap, 
L_BOOL          bSave) 
{ 
   L_INT nRet; 
   HGLOBAL  hGlobal = NULL; 
   L_SIZE_T zUserDataSize; 
   L_UCHAR* pUserData; 
   if (!pBitmap || !hObject) 
      return 0; 
   if (bSave) // saving 
   { 
      nRet = L_SaveBitmapMemory(&hGlobal, pBitmap, FILE_BMP, 24, 0, &zUserDataSize, NULL); 
      if(nRet != SUCCESS) 
         return nRet; 
      pUserData = (L_UCHAR *)GlobalLock(hGlobal); 
      nRet = L_AnnSetUserData(hObject,  pUserData, (L_UINT) zUserDataSize, ANNFLAG_NOINVALIDATE ); 
      if(nRet != SUCCESS) 
         return nRet; 
      GlobalUnlock(hGlobal); 
      GlobalFree(hGlobal); 
   } 
   else // loading 
   { 
      // Load 
      nRet = L_AnnGetUserData(hObject, NULL, (L_UINT*) &zUserDataSize); 
      if(nRet != SUCCESS) 
         return nRet; 
      pUserData = (L_UCHAR *)malloc(zUserDataSize); 
      nRet = L_AnnGetUserData(hObject, pUserData, (L_UINT*) &zUserDataSize); 
      if(nRet != SUCCESS) 
         return nRet; 
      nRet = L_LoadBitmapMemory(pUserData, pBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGRORGRAY, zUserDataSize, NULL, NULL); 
      if(nRet != SUCCESS) 
         return nRet; 
      free(pUserData); 
   } 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help