L_Jp2SaveListMemory

Summary

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

Syntax

#include "l_bitmap.h"

L_LTJP2_API L_INT EXT_FUNCTION L_Jp2SaveListMemory(hJp2, lpBuffer, puBufferSize, hList, eFormat, nBitsPerPixel, nQFactor, pSaveOptions, pSaveCallBack, pUserData)

Parameters

L_HJP2 hJp2

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

L_UINT8 ** lpBuffer

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 GlobalFree() function.

L_SIZE_T *puBufferSize

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

HBITMAPLIST hList

Handle to the list of bitmaps.

eJP2FILEFORMAT eFormat

Output JPEG 2000 file format.

L_INT nBitsPerPixel

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.

L_INT nQFactor

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.

pSAVEFILEOPTION pSaveOptions

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

FILESAVECALLBACK pSaveCallBack

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 FILESAVECALLBACK.

L_VOID * pUserData

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.

Returns

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

Comments

L_Jp2SaveListMemory 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

Platforms

Win32, x64.

See Also

Functions

Topics

Example

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

L_INT Jp2SaveListMemoryExample(HBITMAPLIST hList, L_UINT8* pXMLData, L_SIZE_T uSize) 
{ 
   L_HJP2 hEngine = NULL; 
   L_INT  nRet; 
   L_JP2_XML_BOX XMLBox; 
   L_UINT8* pFileBuffer = NULL; 
   L_SIZE_T uFileSize = 0; 
   HBITMAPLIST hReadList = NULL; 
 
   // Create JPEG  2000 engine handle 
   hEngine = L_Jp2Create(); 
 
   // Create an XML box 
   XMLBox.uStructSize = sizeof(L_JP2_XML_BOX); 
   XMLBox.pData = pXMLData; 
   XMLBox.uDataSize = uSize; 
 
   // Set XML box of JPX engine 
   nRet = L_Jp2SetBoxes(hEngine, L_JPXB_XML, &XMLBox, 1); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   // Save the list in JPx format 
   nRet = L_Jp2SaveListMemory(hEngine, &pFileBuffer, &uFileSize, hList, LEADJP2_JPX, 24, 5, NULL, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   // Load the saved list 
   nRet = L_Jp2ReadListMemory(hEngine, pFileBuffer, uFileSize, &hReadList, 0, ORDER_BGR, NULL, NULL, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   // Destroy engine handle 
   nRet = L_Jp2Destroy(hEngine); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   GlobalFree(pFileBuffer); 
 
   // Free the list 
   nRet = L_DestroyBitmapList(hReadList); 
   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.