LJp2FileFormat::Save

#include "ltwrappr.h"

L_INT LJp2FileFormat::Save(pszFile, pBitmap, eFormat, nBitsPerPixel, nQFactor, pSaveOptions, pSaveCallBack, pUserData)

L_TCHAR * pszFile;

/* JPEG 2000 file name */

pBITMAPHANDLE pBitmap;

/* pointer to the bitmap handle */

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 */

LFile::SaveFileCallBack pSaveCallBack;

/* optional callback function */

L_VOID * pUserData;

/* pointer to more parameters for the callback */

Creates a file in any of the supported JPEG 2000 file formats.  

Parameter

Description

pszFile

Character string that contains the name of the JPEG 2000 file.

pBitmap

Pointer to the bitmap handle that describes the data 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.

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 LFile::SaveFileCallBack.

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

LJp2FileFormat::Save creates a file 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

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:

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

Topics:

Implementing JPEG 2000 Features

 

Raster Image Functions: Working with JPEG 2000

 

Programming with JPX Features

 

JPX File Comments

 

Raster Image Functions: Working with JPX

Example

This example saves/loads bitmap in JPEG 2000 file format

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName
L_INT LJp2FileFormat__SaveExample(L_UINT8 * pXMLData, L_SIZE_T uSize)
{
   LJp2FileFormat Engine;
   L_INT  nRet;
   BITMAPHANDLE TmpBitmap;
   L_JP2_XML_BOX XMLBox;
   pL_JP2_MPEG7_BOX pMPEG7Box;
   L_UINT uNumOfMPEG7;
   /*Load an image*/
   nRet = Engine.Read(MAKE_IMAGE_PATH(TEXT("image1.jpx")),&TmpBitmap,0,ORDER_BGR,NULL, NULL, NULL, NULL);
   if(nRet != SUCCESS)
      return nRet;
   /*Read MPEG7 boxes*/
   nRet = Engine.GetBoxes( L_JPXB_MPEG7, (L_VOID**)&pMPEG7Box,&uNumOfMPEG7);
   if(nRet != SUCCESS)
      return nRet;
   /*Reset all engine boxes*/
   nRet = Engine.ResetBoxes();
   if(nRet != SUCCESS)
      return nRet;
   /*Set JPX Engine Boxes*/
   if(uNumOfMPEG7)
   {
      nRet = Engine.SetBoxes(L_JPXB_MPEG7,pMPEG7Box,uNumOfMPEG7);
      if(nRet != SUCCESS)
         return nRet;
   }
   /*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 image in JPx format*/
   nRet = Engine.Save(MAKE_IMAGE_PATH(TEXT("Test.jpx")), &TmpBitmap,LEADJP2_JPX, 24, 5,NULL, NULL, NULL);
   if(nRet != SUCCESS)
      return nRet;
   /*Free MPEG7 boxes*/
   if(uNumOfMPEG7)
      Engine.FreeBoxes( L_JPXB_MPEG7, pMPEG7Box, uNumOfMPEG7);
   if(TmpBitmap.Flags.Allocated)
      L_FreeBitmap(&TmpBitmap);
   return SUCCESS;
}