L_Jp2ReadBox

#include "l_bitmap.h"

L_LTJP2_API L_INT EXT_FUNCTION L_Jp2ReadBox(hJp2, pszFile, eBoxType, plBox, uBoxIndex)

L_HJP2 hJp2;

/* JPEG 2000 handle */

L_TCHAR * pszFile;

/* JPEG 2000 file name */

eJP2BOXTYPE eBoxType;

/* box type */

L_VOID ** plBox;

/* pointer to a pointer */

L_UINT32 uBoxIndex;

/* box index */

Reads a box of type eBoxType at uBoxIndex from the specified JPEG 2000 file.

Parameter

Description

hJp2

JPEG 2000 engine handle that was created by the L_Jp2Create function.

pszFile

Character string that contains the name of the JPEG 2000 file.

eBoxType

Box type. It specifies the type of the box to be read from the file.

plBox

Pointer to a pointer to be updated with the box data structure.

uBoxIndex

0-based box index. It specifies the box to read.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

L_Jp2ReadBox reads a box of type eBoxType at uBoxIndex from the specified JPEG 2000 file.

If the uBoxIndex is greater than the number of boxes, the function returns: ERROR_INV_PARAMETER.

L_JP2B_RESOLUTION and L_JPXB_RESOLUTION boxes cant be read using this function. All of the engines boxes will be reset and updated with the new loaded boxes only.

You must free the allocated box by calling the L_Jp2FreeBoxes function.

Required DLLs and Libraries

LTJP2
LFJ2K
LTIMGEFX

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

Windows 2000 / XP/Vista.

See Also

Functions:

L_Jp2FreeBoxes, L_Jp2ReadBoxMemory, L_Jp2AppendBoxes, L_Jp2AppendBoxesMemory

Topics:

Programming with JPEG 2000 Features
Raster Image Functions: Working with JPEG 2000

Example

This example reads an MPEG7 box stored in a JPEG 2000 file.

L_LTJP2TEX_API L_INT Jp2ReadBoxExample(L_UINT8 ** pMPEG7Data, L_SIZE_T* puSize)
{
   L_HJP2 hEngine;
   L_INT  nRet;
   pL_JP2_MPEG7_BOX pMPEG7Box;
   L_JP2_FILEINFO Jp2FileInfo;

   /*Create JPEG  2000 engine handle*/
   hEngine = L_Jp2Create();
   
   Jp2FileInfo.uStructSize = sizeof(L_JP2_FILEINFO);
   L_Jp2GetFileInfo(hEngine, TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\image1.jpx"),&Jp2FileInfo);
   if(Jp2FileInfo.MPEG7.uNumOfBoxes == 0)
      return 0;

   nRet = L_Jp2ReadBox(hEngine,TEXT("%UserProfile%\\My Documents\\LEADTOOLS Images\\image1.jpx"),L_JPXB_MPEG7, (L_VOID**)&pMPEG7Box,0);
   if(nRet != SUCCESS)
      return nRet;
   
   *pMPEG7Data = (L_UINT8*)malloc(pMPEG7Box->uDataSize);
   memcpy(*pMPEG7Data, pMPEG7Box->pData,pMPEG7Box->uDataSize);
   *puSize = pMPEG7Box->uDataSize;
   
   /*Free the read box*/
   L_Jp2FreeBoxes(hEngine, L_JPXB_MPEG7, pMPEG7Box, 1);
   /*Free File Info structure*/
   L_Jp2FreeFileInfo(hEngine, &Jp2FileInfo);
   /*Destroy engine handle*/
   L_Jp2Destroy(hEngine);
   return SUCCESS;
}