Creates a file in memory in any of the supported JPEG 2000 file formats.
JPEG 2000 engine handle that was created by the L_Jp2Create function.
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.
Address of a variable to be updated with the size of the memory buffer in bytes.
Pointer to the bitmap handle that describes the data to be saved.
Output JPEG 2000 file format.
Resulting files pixel depth. Possible values are: 8, 12, 16, 24, 32, 48, 64, and 0. Zero  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 FILESAVECALLBACK.
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.
|SUCCESS||The function was successful.|
|< 1||An error occurred. Refer to Return Codes.|
L_Jp2SaveMemory creates a file in memory in any of the supported JPEG 2000 file formats. All of the currently-set engines boxes will also be saved in this file.
Required DLLs and Libraries
This example saves/loads bitmap in JPEG 2000 file format
L_INT Jp2SaveMemoryExample(pBITMAPHANDLE pBitmap, L_UINT8 * pXMLData, L_SIZE_T uSize)
/*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*/
/*Save the image in JPx format*/
nRet = L_Jp2SaveMemory(hEngine, &pFileBuffer, &uFileSize, pBitmap,LEADJP2_JPX, 24, 5,NULL, NULL, NULL);
if(nRet != SUCCESS)
/*Load the saved image*/
nRet = L_Jp2ReadMemory(hEngine,pFileBuffer, uFileSize,pBitmap,0,ORDER_BGR,NULL, NULL, NULL, NULL);
if(nRet != SUCCESS)
/*Destroy engine handle*/
Medical Web Viewer .NET
.NET, Java, Android, and iOS/macOS Assemblies
C API/C++ Class Libraries