L_Jp2SaveCompositeMemory

#include "l_bitmap.h"

L_LTJP2_API L_INT EXT_FUNCTION L_Jp2SaveCompositeMemory(hJp2, lpBuffer, puBufferSize, pComposite, eFormat, nBitsPerPixel, nQFactor, pSaveOptions, pSaveCallBack, pUserData)

L_HJP2 hJp2;

JPEG 2000 engine handle

L_UINT8 ** lpBuffer;

pointer to pointer

L_SIZE_T *puBufferSize;

pointer to a variable to be updated

pL_JP2_JPXCOMPOSITE pComposite;

pointer to the L_JP2_JPXCOMPOSITE structure

eJP2FILEFORMAT eFormat;

output file format

L_INT nBitsPerPixel;

resulting files pixel depth

L_INT nQFactor;

quality factor

pSAVEFILEOPTION pSaveOptions;

pointer to optional extended save options

FILESAVECALLBACK pSaveCallBack;

optional callback function

L_VOID * pUserData;

pointer to more parameters for the callback

Creates a file in memory in any of the supported JPEG 2000 file formats, using the layer information you provide in pComposite.  

Parameter

Description

hJp2

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

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.

puBufferSize

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

pComposite

Pointer to the L_JP2_JPXCOMPOSITE structure that provides information (color, opacity, pre-opacity, and compression) for all layers to be saved.

eFormat

Output JPEG 2000 file format.

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.

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.

pSaveOptions

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

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.

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

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

L_Jp2SaveCompositeMemory creates a file in memory in any of the supported JPEG 2000 file formats, using the layer information you provide in pComposite. The color bitmap must be allocated in all layers. If any color bitmap is not allocated, the function will return: ERROR_NO_BITMAP. All of the engines boxes will be reset. The JPEG 2000 part 1 (JP2) file format supports only one layer. If you set more than one layer in pComposite, only the first layer will be saved. Also, the JPEG 2000 part 1 (JP2) file format does not support multiple codestreams, so only the color bitmap will be saved. All of the currently-set engines boxes will also be saved in this file.

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

Win32, x64.

See Also

Functions:

L_Jp2Read, L_Jp2ReadList, L_Jp2ReadComposite, L_Jp2ReadFrames, L_Jp2Save, L_Jp2SaveList, L_Jp2SaveComposite, L_Jp2AppendFrames, L_Jp2ReadMemory, L_Jp2ReadListMemory, L_Jp2ReadCompositeMemory, L_Jp2ReadFramesMemory, L_Jp2SaveMemory, L_Jp2SaveListMemory, L_Jp2AppendFramesMemory, L_SaveBitmapList

Topics:

Programming with JPEG 2000 Features

Programming with JPX Features

 

 

Raster Image Functions: Working with JPEG 2000

 

Raster Image Functions: Working with JPX

Example

This example saves/loads composite bitmaps in JPEG 2000 file format

L_INT Jp2SaveCompositeMemoryExample(pL_JP2_JPXCOMPOSITE pComposite, L_UINT8 * pXMLData, L_SIZE_T uSize) 
{ 
   L_HJP2 hEngine; 
   L_INT  nRet; 
   L_UINT i; 
   L_JP2_XML_BOX XMLBox; 
   L_UINT8* pFileBuffer; 
   L_SIZE_T uFileSize; 
   L_JP2_JPXCOMPOSITE Composite = {0}; 
   /*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*/ 
   L_Jp2SetBoxes(hEngine,L_JPXB_XML,&XMLBox,1); 
   /*Save the image in JPx format*/ 
   nRet = L_Jp2SaveCompositeMemory(hEngine, &pFileBuffer, &uFileSize, pComposite,LEADJP2_JPX, 24, 5,NULL, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   Composite.uStructSize = sizeof(L_JP2_JPXCOMPOSITE); 
   /*Load the compiste images*/ 
   nRet = L_Jp2ReadCompositeMemory(hEngine, pFileBuffer, uFileSize, &Composite,0,ORDER_BGR,NULL, NULL, NULL, NULL); 
   if(nRet != SUCCESS) 
      return nRet; 
   /*Free the read composite bitmaps*/ 
   for(i = 0; i < Composite.uNumOfBitmaps; i++) 
   { 
      if(Composite.pBitmaps[i].ColorBitmap.Flags.Allocated) 
         L_FreeBitmap(&Composite.pBitmaps[i].ColorBitmap); 
      if(Composite.pBitmaps[i].OpacityBitmap.Flags.Allocated) 
         L_FreeBitmap(&Composite.pBitmaps[i].OpacityBitmap); 
      if(Composite.pBitmaps[i].PreOpacityBitmap.Flags.Allocated) 
         L_FreeBitmap(&Composite.pBitmaps[i].PreOpacityBitmap); 
   } 
   /*Free composite structure*/ 
   L_Jp2FreeComposite(hEngine, &Composite); 
   /*Destroy engine handle*/ 
   L_Jp2Destroy(hEngine); 
   GlobalFree(pFileBuffer); 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C API Help