L_NITFGetVectorHandle

#include "ltntf.h"

L_LTNTF_API  pVECTORHANDLE L_NITFGetVectorHandle(hNitf, uIndex)

HNITF hNitf;

/* handle to an existing NITF file */

L_UINT32 uIndex;

/* index of the graphics data */

Gets the handle for the graphics data at a specified index in the graphic segment.

Parameter

Description

hNitf

Handle to an existing NITF file, created by calling the L_NITFCreate function.

uIndex

A zero-based index of the graphic data in the hNitf handle.

Returns

!NULL

The function was successful and a vector handle will be returned.

NULL

An error occurred.

Comments

To set the handle for the graphic data in the graphic segment in the NITF file at specified index, call the L_NITFSetVectorHandle function.

When the returned graphics data handle is no longer needed, it should be freed by calling  L_VecFree function.

For every successful call to L_NITFGetVectorHandle that returns a valid graphics data handle, there must be a call to L_VecFree to free this returned handle.

Required DLLs and Libraries

LTNTF

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

 L_VecFree, L_NITFCreate, L_NITFSetVectorHandle

Topics:

NITF Functions: Getting and Setting Graphic Data

 

Programming with LEADTOOLS NITF Functions

Example

L_LTNTFTEX_API L_INT NITFGetVectorHandleExample(L_VOID)
{
   L_INT nRet;
   HNITF hNitf;
   L_UINT uFlags = 0;
   pVECTORHANDLE pVectorHandle = NULL;
   L_UINT uCount;
   L_UINT i = 0;
   L_TCHAR pszFile[MAX_PATH];
   L_UnlockSupport(L_SUPPORT_VECTOR, L_KEY_VECTOR);
   // Create hNitf handle and parse the NITF file
   nRet =L_NITFCreate(&hNitf, TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 16\\Images\\test.ntf"));
   if(nRet !=SUCCESS)
      return nRet;
   // Check if the hNITF is empty or invalid
   uFlags = L_NITFGetStatus(hNitf);
   if((uFlags & NITF_FILE_EMPTY) == NITF_FILE_EMPTY)
   {
      MessageBox(NULL ,TEXT("NITF file is empty"),NULL,MB_OK);
      return FAILURE;
   }
   if((uFlags & NITF_FILE_VALID) != NITF_FILE_VALID)
   {
      MessageBox(NULL,TEXT("NITF file is invalid"),NULL,MB_OK);
      return FAILURE;
   }
   // Save all the graphic segments into separated files
   uCount = L_NITFGetGraphicHeaderCount(hNitf);
   for( i = 0; i < uCount; ++i)
   {
      pVectorHandle = L_NITFGetVectorHandle(hNitf, i);
      if(pVectorHandle == NULL)
         return FAILURE;
      memset(pszFile, 0, sizeof(pszFile));
      wsprintf(pszFile, TEXT("c:\\GraphicSeg%d.cgm"), i+1);
      nRet =L_VecSaveFile(pszFile, pVectorHandle, FILE_CGM, NULL);
      if(nRet !=SUCCESS)
         return nRet;
      nRet =L_VecFree(pVectorHandle);
      if(nRet !=SUCCESS)
         return nRet;
   }
   nRet =L_NITFDestroy(&hNitf);
   if(nRet !=SUCCESS)
      return nRet;
   return SUCCESS;
}