L_Jp2ExtractFramesBuffer

#include "l_bitmap.h"

L_LTJP2_API L_INT EXT_FUNCTION L_Jp2ExtractFramesBuffer(hJp2, pInFileName, lpBuffer, puBufferSize, puFrames, uNumOfFrames)

L_HJP2 hJp2;

/* JPEG 2000 engine handle */

L_TCHAR * pInFileName;

/* name of the input file */

L_UCHAR ** lpBuffer;

/* pointer to a pointer */

L_SIZE_T * puBufferSize;

/* pointer to a variable to be updated */

L_UINT32 * puFrames;

/* frames indices */

L_UINT32 uNumOfFrames;

/* number of frames to be extracted */

Extracts the frames that are specified by puFrames from the input file and save them into a new JPEG 2000 file in a memory buffer that is allocated by the function contains only the extracted frames headers and codestreams directly not through decompressing/compressing process.  This function is available in the Document/Medical Toolkits.

Parameter

Description

hJp2

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

pInFileName

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

lpBuffer

Pointer to a pointer to be updated with an array of bytes that contains a JPEG 2000 file with extracted frames only. You must free this buffer by calling the Windows GlobalFree () function.

puBufferSize

Address of a variable to be updated with the size of the memory buffer in bytes.

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.

uNumOfFrames

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

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

L_Jp2ExtractFramesBuffer extracts the specified frames from the input file and save them into a new JPEG 2000 file in a memory buffer that is allocated by the function 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 in a memory buffer.

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_Jp2ExtractFrames, L_Jp2ExtractFramesBufferMemory, L_Jp2AppendFrames, L_Jp2AppendGMLData, L_Jp2ReadBox, L_Jp2ReadGMLData, L_Jp2ReadFrames, L_Jp2FragmentJpxFile

Topics:

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

Example

This example extracts a frame from JPX file.

L_LTJP2TEX_API L_INT Jp2ExtractFramesBufferExample(L_UINT8** lpOutBuffer, L_SIZE_T * puSize)
{
   L_HJP2 hEngine;
   L_JP2_FILEINFO Jp2FileInfo;
   L_UINT32 puFrames[1];
   
   *lpOutBuffer = NULL;
   *puSize = 0;

   /*Create JPEG  2000 engine handle*/
   hEngine = L_Jp2Create();

   Jp2FileInfo.uStructSize = sizeof(L_JP2_FILEINFO);
   L_Jp2GetFileInfo(hEngine, TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\image1.jpx"),&Jp2FileInfo);
   
   if(Jp2FileInfo.uNumOfFrames < 2)
      return 0;

   /*Extract the second frame*/
   puFrames[0] = 1;

   L_Jp2ExtractFramesBuffer(hEngine, TEXT("C:\\Program Files\\LEAD Technologies\\LEADTOOLS 15\\Images\\image1.jpx"), lpOutBuffer, puSize, puFrames, 1);

   /*Free File Info structure*/
   L_Jp2FreeFileInfo(hEngine, &Jp2FileInfo);
   /*Destroy engine handle*/
   L_Jp2Destroy(hEngine);
   return SUCCESS;
}