LEADTOOLS Raster Imaging C++ Class Library Help > Classes and Member Functions > LJp2FileFormat > LJp2FileFormat Member Functions > LJp2FileFormat::ReadBoxMemory |
#include "ltwrappr.h"
L_INT LJp2FileFormat::ReadBoxMemory(pBuffer, uBufferSize, eBoxType, plBox, uBoxIndex)
L_UINT8 * pBuffer; |
/* pointer to a JPEG 2000 file in memory */ |
L_SIZE_T uBufferSize; |
/* size of JPEG 2000 file in bytes */ |
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 a JPEG 2000 file in memory.
Parameter |
Description |
pBuffer |
Pointer to a JPEG 2000 file in memory. |
uBufferSize |
Size of JPEG 2000 file in bytes. |
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 |
Zero based box index. It specifies the box the user wants to read. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
LJp2FileFormat::ReadBoxMemory reads a box of type eBoxType at uBoxIndex from a JPEG 2000 file in memory.
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.
Required DLLs and Libraries
LTJP2 For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Win32, x64.
See Also
Functions: |
LJp2FileFormat::FreeBoxes, LJp2FileFormat::ReadBox, LJp2FileFormat::AppendBoxes, LJp2FileFormat::AppendBoxesMemory |
Topics: |
|
|
|
|
|
|
|
|
Example
This example reads an MPEG7 box stored in a JPEG 2000 file.
L_INT LJp2FileFormat__ReadBoxMemoryExample(L_UINT8* pFileBuffer, L_SIZE_T uFileSize, L_UINT8 ** pMPEG7Data, L_SIZE_T* puSize) { LJp2FileFormat Engine; L_INT nRet = 0; pL_JP2_MPEG7_BOX pMPEG7Box; L_JP2_FILEINFO Jp2FileInfo; Jp2FileInfo.uStructSize = sizeof(L_JP2_FILEINFO); nRet = Engine.GetFileInfoMemory( pFileBuffer, uFileSize,&Jp2FileInfo); if(nRet != SUCCESS) return nRet; if(Jp2FileInfo.MPEG7.uNumOfBoxes == 0) return 0; nRet = Engine.ReadBoxMemory(pFileBuffer, uFileSize,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*/ nRet = Engine.FreeBoxes( L_JPXB_MPEG7, pMPEG7Box, 1); if(nRet != SUCCESS) return nRet; /*Free File Info structure*/ nRet = Engine.FreeFileInfo( &Jp2FileInfo); if(nRet != SUCCESS) return nRet; return SUCCESS; }