#include "ltntf.h"
L_LTNTF_API L_INT L_NITFCreate(phNitf, pszFileName)
Creates an empty NITF file or parses an existing NITF file.
Pointer to a NITF file handle.
Character string that contains the name of the NITF file to be parsed.
| Value | Meaning |
|---|---|
| SUCCESS | The function was successful. |
| < 1 | An error occurred. Refer to Return Codes. |
L_NITFCreate must be called before calling any other L_NITFXXX functions.
To create an empty NITF file, pass the pszFileName parameter as NULL.
To parse an existing NITF file, pass a valid file name to the pszFileName parameter.
To save the created NITF file, call the L_NITFSaveFile function.
When the NITF file handle is no longer needed, it should be freed by calling L_NITFDestroy function. For every call to L_NITFCreate there must be a call to L_NITFDestroy.
Required DLLs and Libraries
// This example will create an empty NITF file and add image, graphic and text segments
L_INT NITFCreateExample(L_VOID){BITMAPHANDLE Bitmap;HNITF hNitf;VECTORHANDLE Vector;L_INT nRet;// Create hNitf HandlenRet =L_NITFCreate(&hNitf, NULL);if(nRet !=SUCCESS)return nRet;// Load and append Image segmentnRet =L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("cannon.jpg")), &Bitmap, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL);if(nRet !=SUCCESS)return nRet;nRet =L_NITFAppendImageSegment(hNitf, &Bitmap, FILE_JPEG, 24, 2);if(nRet !=SUCCESS)return nRet;// Load and append graphic segmentRECT rcViewPort;SetRect(&rcViewPort, 0, 0, 640, 480);nRet = L_VecLoadFile(MAKE_IMAGE_PATH(TEXT("random.dxf")), &Vector, NULL, NULL);if(nRet== SUCCESS){nRet =L_NITFAppendGraphicSegment(hNitf, &Vector, &rcViewPort);if(nRet !=SUCCESS)return nRet;}// Free vector handleL_VecFree(&Vector);// Append Text segmentnRet =L_NITFAppendTextSegment(hNitf, MAKE_IMAGE_PATH(TEXT("2.txt")));if(nRet !=SUCCESS)return nRet;// Saving hNitf HandlenRet =L_NITFSaveFile(hNitf, MAKE_IMAGE_PATH(TEXT("test.ntf")));if(nRet !=SUCCESS)return nRet;nRet =L_NITFDestroy(&hNitf);if(nRet !=SUCCESS)return nRet;// Free bitmap handleL_FreeBitmap(&Bitmap);return SUCCESS;}