L_NITFGetTextSegment

#include "ltntf.h"

L_LTNTF_API L_INT L_NITFGetTextSegment(hNitf, uIndex, pTextBuffer, puBufferSize)

HNITF hNitf;

handle to the NITF file

L_UINT uIndex;

index of the text data in the text segment

L_CHAR* pTextBuffer;

text data buffer

L_UINT * puBufferSize;

size of the buffer pointed to by pTextBuffer

Retrieves a buffer for the text data at a specified index in the text segment.

Parameter

Description

hNitf

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

uIndex

A zero-based Index of the text data in the text segment.

pTextBuffer

Pointer to a buffer to be updated with the text data.

puBufferSize

Pointer to a variable to be updated with the length of the text data intended to retrieve.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

To use this function:

1.

Call this function passing pTextBuffer as NULL to obtain the text length in the puBufferSize parameter.

2.

Allocate a buffer of size (*puBufferSize + 1).

3.

Call this function passing the allocated buffer to the pTextBuffer parameter to obtain the text data.

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_NITFGetTextHeaderCount, L_NITFGetTextHeader, L_NITFSetTextHeader.

Topics:

NITF Functions: Getting and Setting Text Data

 

Programming with LEADTOOLS NITF Functions

Example

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
L_INT NITFGetTextSegmentExample(L_VOID) 
{ 
   L_INT nRet = SUCCESS; 
   HNITF hNitf; 
   L_UINT uFlags = 0; 
   TXTHEADER TextHeader; 
   L_UINT uCount; 
   L_UINT i = 0; 
   memset(&TextHeader, 0, sizeof(TXTHEADER)); 
   //Create hNitf Handle and Parse the NITF File 
   nRet =L_NITFCreate (&hNitf, MAKE_IMAGE_PATH(TEXT("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 Text Header 
   uCount = L_NITFGetTextHeaderCount(hNitf); 
   for( i = 0; i < uCount; ++i) 
   { 
      L_UINT uBufferSize =0; 
      L_CHAR * pTextBuffer = NULL; 
      L_NITFGetTextSegment(hNitf, i, NULL, &uBufferSize); 
      if(uBufferSize > 0) 
      { 
         pTextBuffer = (L_CHAR*)malloc(uBufferSize + 1); 
         if(pTextBuffer) 
         { 
            L_NITFGetTextSegment(hNitf, i, pTextBuffer, &uBufferSize); 
            MessageBoxA(NULL, pTextBuffer, "Text Segment", 0); 
            free(pTextBuffer); 
            pTextBuffer = NULL; 
         } 
      } 
   } 
   nRet =L_NITFDestroy(&hNitf); 
   if(nRet !=SUCCESS) 
      return nRet; 
   return SUCCESS; 
} 

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