L_Jp2ExtractFrames

Summary

Extracts the frames that are specified by puFrames from the input file, and saves them into a new JPEG 2000 file contains only the extracted frames headers and codestreams directly not through decompressing/compressing process.

Syntax

#include "l_bitmap.h"

L_LTJP2_API L_INT EXT_FUNCTION L_Jp2ExtractFrames(hJp2, pInFileName, pOutFileName, puFrames, uNumOfFrames)

Parameters

L_HJP2 hJp2

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

L_TCHAR * pInFileName

Character string that contains the name of the JPEG 2000 file to extract frames from it.

L_TCHAR * pOutFileName

Character string that contains the name of the new JPEG 2000 file that contains the extracted frames only.

L_UINT32 * puFrames

Array of unsigned integers specifies the indices of the frames to be extracted from the input JPEG 2000 file. All indices shall be 0-based. If any frames index is out the frames number the function will return ERROR_INV_PARAMETER.

L_UINT32 uNumOfFrames

Number of frames to be extracted. This field specifies the size of puFrames array.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

L_Jp2ExtractFrames extracts the specified frames from the input file and save them into a new JPEG 2000 file contains only the extracted frames headers and codestreams directly not through decompressing/compressing process so it saves processor time and memory. This function is very suitable to server application where multiple clients request specific frames of a JPEG 2000 file so instead of decompressing then compressing the frames this function copies only the needed frames data to generate them and saves the data into a new JPEG 2000 file.

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

This example extracts a frame from JPX file.

L_INT Jp2ExtractFramesExample(L_VOID) 
{ 
   L_HJP2 hEngine; 
   L_JP2_FILEINFO Jp2FileInfo; 
   L_UINT32 puFrames[1]; 
   L_INT nRet; 
 
   // Create JPEG  2000 engine handle 
   hEngine = L_Jp2Create(); 
 
   Jp2FileInfo.uStructSize = sizeof(L_JP2_FILEINFO); 
   L_Jp2GetFileInfo(hEngine, MAKE_IMAGE_PATH("image1.jpx"), &Jp2FileInfo); 
   if (Jp2FileInfo.MPEG7.uNumOfBoxes == 0) 
      return 0; 
 
   if (Jp2FileInfo.uNumOfFrames < 2) 
      return 0; 
 
   if (Jp2FileInfo.DataRef.uNumOfBoxes) 
      return 0; 
 
   // Extract the second frame 
   puFrames[0] = 1; 
 
   nRet = L_Jp2ExtractFrames(hEngine, MAKE_IMAGE_PATH("image1.jpx"), MAKE_IMAGE_PATH("Test.jpx"), puFrames, 1); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   // Free File Info structure 
   nRet = L_Jp2FreeFileInfo(hEngine, &Jp2FileInfo); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   // Destroy engine handle 
   nRet = L_Jp2Destroy(hEngine); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
} 

Help Version 22.0.2023.7.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.