| LEADTOOLS DICOM C DLL Help > Function References > L_DicomSetJ2KOptions | 
#include "ltdic.h"
L_LTDIC_API L_UINT16 L_DicomSetJ2KOptions(hDS, pOptions)
| HDICOMDS hDS; | /* a DICOM handle */ | 
| const pFILEJ2KOPTIONS pOptions; | /* pointer to a structure */ | 
Sets the JPEG 2000 compression options.
| Parameter | Description | 
| hDS | A DICOM handle. | 
| pOptions | Pointer to a structure that contains the options to use when compressing the image(s) in a Pixel Data element using the JPEG 2000 compression. | 
Returns
| DICOM_SUCCESS | The function was successful. | 
| >0 | An error occurred. Refer to Return Codes. | 
Comments
The nSize member of the FILEJ2KOPTIONS structure must be set before calling this function.
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, Linux.
See Also
| Functions: | L_DicomInsertImage, L_DicomInsertImageList, L_DicomSetImage, L_DicomSetImageList, L_DicomGetJ2KOptions, L_DicomGetDefaultJ2KOptions | 
| Topics: | |
| 
 | 
Example
This example inserts an image in a Data Set Using the JPEG 2000 compression with a 100:1 compression ratio
L_INT DicomSetJ2KOptionsExample(HDICOMDS hDS, pBITMAPHANDLE pBitmap)
{
   L_UINT16 nRet;
   if(hDS && pBitmap)
   {
      pDICOMELEMENT pElement;
      FILEJ2KOPTIONS J2KOptions;
      
      // Get the current JPEG 2000 compression options. 
      nRet = L_DicomGetJ2KOptions(hDS, &J2KOptions, sizeof(FILEJ2KOPTIONS));
      if (nRet != DICOM_SUCCESS)
         return nRet;
      J2KOptions.uCompressionControl = J2K_COMPRESSION_RATIO;
      // set the compression ratio to 100
      J2KOptions.fCompressionRatio = 100.0f;
      // Update the JPEG 2000 compression options. 
      nRet = L_DicomSetJ2KOptions(hDS, &J2KOptions);
      if (nRet != DICOM_SUCCESS)
         return nRet;
      pElement = L_DicomFindFirstElement(hDS, NULL, TAG_PIXEL_DATA, FALSE);
      if (pElement != NULL)
      {
         nRet = L_DicomInsertImage(hDS,
            pElement,
            pBitmap,
            1,
            IMAGE_COMPRESSION_J2K_LOSSY,
            IMAGE_PHOTOMETRIC_MONOCHROME2,
            0,
            25,
            DICOM_SETIMAGE_AUTO_SET_VOI_LUT,
            NULL,
            NULL);
         if (nRet != DICOM_SUCCESS)
            return nRet;
      }
   }
   return DICOM_SUCCESS;
}