L_NITFGetImageHeader

#include "ltntf.h"

L_LTNTF_API L_INT L_NITFGetImageHeader(hNitf, uIndex, pImageHeader)

HNITF hNitf;

/* handle to an existing NITF file */

L_UINT uIndex;

/* index of the image segment*/

pIMAGEHEADER pImageHeader;

/* pointer to a IMAGEHEADER structure */

Retrieves the image header information of a specific 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 image segment in the hNitf handle.

pImageHeader

Pointer to an IMAGEHEADER structure to be updated with the image header information of the specified image segment at the index uIndex.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

To retrieve the number of the image segments available in the hNitf handle, call the L_NITFGetImageHeaderCount function.

To change the image header information for a specific graphic segment, call the L_NITFSetImageHeader function.

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_NITFCreate, L_NITFGetImageHeaderCount, L_NITFSetImageHeader

Topics:

NITF Functions: Getting and Setting Header Information

 

Programming with LEADTOOLS NITF Functions

Example

L_LTNTFTEX_API L_INT NITFGetImageHeaderExample(L_VOID)
{
   L_INT nRet = SUCCESS;
   HNITF hNitf;
   L_UINT uFlags = 0;
   IMAGEHEADER ImageHeader;
   L_UINT uCount;
   L_UINT i = 0;
   memset(&ImageHeader, 0, sizeof(IMAGEHEADER));
   // 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;
   }
   // Update the image header
   uCount = L_NITFGetImageHeaderCount(hNitf);
   for( i = 0; i < uCount; ++i)
   {
       memset(&ImageHeader, 0, sizeof(ImageHeader));
      nRet = L_NITFGetImageHeader(hNitf, i, &ImageHeader); 
      if(nRet == SUCCESS)
      {
         ImageHeader.nILOCCol = 50;
         ImageHeader.nILOCRow = 50;
         nRet =L_NITFSetImageHeader(hNitf, i, &ImageHeader);
         if(nRet !=SUCCESS)
            return nRet;
         L_NITFFreeImageHeader(&ImageHeader);
      }
      else
         return nRet;
   }
   nRet =L_NITFDestroy(&hNitf);
   if(nRet !=SUCCESS)
      return nRet;
   return SUCCESS;
}