#include "ltwrappr.h"

L_INT LJp2FileFormat::SaveListMemory(lpBuffer, puBufferSize, hList, eFormat, nBitsPerPixel, nQFactor, pSaveOptions, pSaveCallBack, pUserData)

L_UINT8 ** lpBuffer;

pointer to pointer

L_SIZE_T *puBufferSize;

pointer to a variable to be updated


handle to the list of bitmaps


output file format

L_INT nBitsPerPixel;

resulting files pixel depth

L_INT nQFactor;

quality factor


pointer to optional extended save options

LFile::SaveFileCallBack pSaveCallBack;

optional callback function

L_VOID * pUserData;

pointer to more parameters for the callback

Saves a list of bitmaps, to a file in memory in any supported JPEG 2000 format.  




Pointer to a memory buffer pointer that will be updated with a new memory buffer pointer that contains the saved image. You must free this buffer by calling the Windows LocalFree() function.


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


Handle to the list of bitmaps.


Output JPEG 2000 file format.


Resulting files pixel depth. Possible values are: 8, 12, 16, 24, 32, 48, 64, and 0. Zero [0] means that each bitmap will be saved with its bits per pixel value, if that value is equal to one of the possible values (8, 12, 16, 24, 32, 48, or 64). If it is not one of the possible values, it will return: ERROR_J2K_UNSUPPORTED.


Quality factor. This value determines the degree of loss in the compression process. Possible values are from 0 to 255. Zero (0) represents lossless compression. Values between 1 and 255 are interpreted as a compression ratio.


Pointer to optional extended save options. Pass NULL to use the default save options.


Optional callback function for additional processing.


If you do not provide a callback function, pass NULL.


If you provide a callback function, use the function pointer as the value of this parameter.


The callback function must adhere to the syntax described in LFile::SaveFileCallBack.


Void pointer you can use to pass one or more additional parameters used by the callback function.


To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.


If additional parameters are not needed, pass NULL.



The function was successful.

< 1

An error occurred. Refer to Return Codes.


LJp2FileFormat::SaveListMemory saves a list of bitmaps, to a file in memory in any supported JPEG 2000 format. However, note that the JPEG 2000 part 1 (JP2) file format does not support multiple codestreams. Therefore, if eFormat passes JP2, only the first bitmap in the list will be saved. All of the currently-set engines boxes will also be saved in this file.

Required DLLs and Libraries


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


LJp2FileFormat::Read, LJp2FileFormat::ReadList, LJp2FileFormat::ReadComposite, LJp2FileFormat::ReadFrames, LJp2FileFormat::Save, LJp2FileFormat::SaveList, LJp2FileFormat::SaveComposite, LJp2FileFormat::AppendFrames, LJp2FileFormat::ReadMemory, LJp2FileFormat::ReadListMemory, LJp2FileFormat::ReadCompositeMemory, LJp2FileFormat::ReadFramesMemory, LJp2FileFormat::SaveMemory, LJp2FileFormat::SaveCompositeMemory, LJp2FileFormat::AppendFramesMemory, LBitmapList::Save


Implementing JPEG 2000 Features


Raster Image Functions: Working with JPEG 2000


Programming with JPX Features


JPX File Comments


Raster Image Functions: Working with JPX


This example saves/loads bitmap list in JPEG 2000 file format

L_INT LJp2FileFormat__SaveListMemoryExample(HBITMAPLIST hList, L_UINT8 * pXMLData, L_SIZE_T uSize ) 
   LJp2FileFormat Engine; 
   L_INT  nRet; 
   L_UINT8* pFileBuffer; 
   L_SIZE_T uFileSize; 
   HBITMAPLIST hReadList; 
   /*Create an XML box*/ 
   XMLBox.uStructSize = sizeof(L_JP2_XML_BOX); 
   XMLBox.pData = pXMLData; 
   XMLBox.uDataSize = uSize; 
   /*Set XML box of JPX engine*/ 
   nRet = Engine.SetBoxes(L_JPXB_XML,&XMLBox,1); 
   if(nRet != SUCCESS) 
      return nRet; 
   /*Save the list in JPx format*/ 
   nRet = Engine.SaveListMemory(&pFileBuffer, &uFileSize, hList,LEADJP2_JPX, 24, 5, NULL, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   /*Load the saved list*/ 
   nRet = Engine.ReadListMemory(pFileBuffer, uFileSize,&hReadList,0,ORDER_BGR,NULL, NULL, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   LBitmapList List ; 
   return SUCCESS; 

Help Version 20.0.2018.2.25
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C++ Class Library Help