L_DicomChangeTransferSyntax2

#include "Ltdic.h"

L_LTDIC_API L_UINT16 L_DicomChangeTransferSyntax2(hDS, pszOutfile, pszUID, nQFactor, uFlags, uSaveFlags)

HDICOMDS hDS;

a DICOM handle

L_TCHAR * pszOutfile;

character string that contains the name of the output file

L_TCHAR * pszUID;

character string

L_INT32 nQFactor;

quality factor

L_UINT32 uFlags;

flags that indicates how the compression will be performed

L_UINT16 uSaveFlags;

flags that indicate the file characteristics to use when saving the file

Changes the transfer syntax of the data set.

Parameter Description
hDS A DICOM handle to the data set.
pszOutfile Character string that contains the name of the output file.
pszUID Character string that contains the UID of the new transfer syntax. Possible values are:
Value Meaning
UID_IMPLICIT_VR_LITTLE_ENDIAN "1.2.840.10008.1.2"
UID_EXPLICIT_VR_LITTLE_ENDIAN "1.2.840.10008.1.2.1"
UID_EXPLICIT_VR_BIG_ENDIAN "1.2.840.10008.1.2.2"
UID_JPEG_BASELINE_1 "1.2.840.10008.1.2.4.50"
UID_JPEG_EXTENDED_2_4 "1.2.840.10008.1.2.4.51"
UID_JPEG_LOSSLESS_NONHIER_14 "1.2.840.10008.1.2.4.57"
UID_JPEG_LOSSLESS_NONHIER_14B "1.2.840.10008.1.2.4.70"
TRANSFER_SYNTAX_JPEG_LS_LOSSLESS "1.2.840.10008.1.2.4.80"
TRANSFER_SYNTAX_JPEG_LS_LOSSY "1.2.840.10008.1.2.4.81"
UID_JPEG2000_LOSSLESS_ONLY "1.2.840.10008.1.2.4.90"
UID_JPEG2000 "1.2.840.10008.1.2.4.91"
TRANSFER_SYNTAX_JPEG_2000_PART_2_MULTI_COMPONENT_IMAGE_COMPRESSION_LOSSLESS_ONLY "1.2.840.10008.1.2.4.92"
TRANSFER_SYNTAX_JPEG_2000_PART_2_MULTI_COMPONENT_IMAGE_COMPRESSION "1.2.840.10008.1.2.4.93"
UID_RLE_LOSSLESS "1.2.840.10008.1.2.5"
nQFactor The quality factor (Q factor) is a number that determines the degree of loss in the compression process. You can set a value from 2 to 255, where 2 is the highest quality and 255 is the most compression. This parameter only applies when the new transfer syntax will involve compressing pixel data using a lossy compression.
uFlags Flag that indicates how the compression will be performed. Possible values are:
Value Meaning
DICOM_CHANGETRAN_MINIMIZE_JPEG_SIZE [0x00000001] If set, and the new transfer syntax uses JPEG compression, the JPEG compression engine will use optimized Huffman tables, which results in better compression, but slower speed.
DICOM_CHANGETRAN_RESCALE_MODALITY_LUT_WHEN_LOSSY_COMPRESSED [0x00000002] If set, and the new transfer syntax uses JPEG lossy compression, any modality LUT present will be rescaled to account for changes in minimum and maximum grayscale values due to lossy compression.
DICOM_CHANGETRAN_YBR_FULL [0x00000100] This flag is valid only for color images, and if pszUID is one of the following:
  • UID_IMPLICIT_VR_LITTLE_ENDIAN
  • UID_EXPLICIT_VR_LITTLE_ENDIAN
  • UID_EXPLICIT_VR_BIG_ENDIAN
  • UID_RLE_LOSSLESS

It is ignored for all other transfer syntax values. If set, this converts the RGB image data to YCbCr, which is one luminance (Y) and two chrominance planes (CB and CR).

uSaveFlags Flag that indicates how the compression will be performed. Possible values are:
Value Meaning
DS_METAHEADER_PRESENT [0x0001] The header is present. This can be used with compressed or uncompressed images.
DS_METAHEADER_ABSENT [0x0002] The header is absent. This can be used only with uncompressed images.
DS_GROUP_LENGTHS [0x0040] Include an entry in the file for each group with the group number and the number of elements that group has.
DS_LENGTH_EXPLICIT [0x0080] The length of a sequence (in bytes) is encoded as a 32-bit integer and no Sequence delimitation item is included at the end of the sequence.
DS_EXCLUDE_METAHEADER_GROUP [0x0100] Elements with the tag number 0x0002xxxx will not be saved in the file.

Returns

DICOM_SUCCESS The function was successful.
>0 An error occurred. Refer to Return Codes.

Comments

This function will convert the data set's transfer syntax to the transfer syntax specified in pszUID, maintaining all elements and values in the data set. Additionally, the resulting dataset is saved as a file pszOutFile using the characteristics specified by uSaveFlags.

After this function is called all previous references to data elements in the data set will no longer be valid.

This function is especially useful when sending a C_STORE_REQ message using the L_DicomSendCStoreRequest function. The user can match the data set transfer syntax with the transfer syntax of the SCP.

If this function returns the error DICOM_ERROR_WRITE, one of the causes could be that your system is missing the LEADTOOLS file filter LFCMPU.DLL. Specifically, this error will be returned if either the original transfer syntax or the new transfer syntax is one of the following:

L_DicomChangeTransferSyntax2 does everything that L_DicomChangeTransferSyntax does, but additionally saves a dataset with the new transfer syntax at the location pszOutFile with save options specified by uSaveFlags. Note that L_DicomChangeTransferSyntax2 should be used when trying to produce a file with the new transfer syntax, as opposed to L_DicomChangeTransferSyntax followed by calling L_DicomSaveDS. Using L_DicomChangeTransferSyntax2 to produce a file will be significantly faster and use fewer resources (memory and disk), especially for large files.

Passing NULL for pszOutFile if you do not want to save the resulting dataset as a file. In this case, the uSaveFlags are ignored. This is functionally equivalent to calling L_DicomChangeTransferSyntax.

Make sure that the LFCMPU.DLL is in the same folder as the other LEAD DLLS. For more information see Files To Be Included With Your Application.

Note: This function cannot be used to encode DICOM transfer syntaxes (e.g. video compression support) that are not part of the main medical SDK and it is supported only via the LEADTOOLS Medical Multimedia Module.

Required DLLs and Libraries

LTDIC
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, Linux.

See Also

Functions: L_DicomSendCStoreRequest, L_DicomChangeTransferSyntax
Topics: Working with Data Sets
Data Sets: Getting and Setting Data Set Information

Example

L_INT DicomChangeTransferSyntax2Example(L_VOID) 
{ 
   L_UINT16 nRet; 
   HDICOMDS hDS = L_DicomCreateDS(NULL); 
 
   // Load a Data Set 
   nRet = L_DicomLoadDS(hDS,MAKE_IMAGE_PATH(TEXT("Image1.dcm")), 0); 
   if(nRet != DICOM_SUCCESS) 
   { 
      L_DicomFreeDS(hDS); 
      return nRet; 
   } 
 
   // Change the Transfer Syntax to Explicit VR Big Endian, and save the new dataset 
   nRet = L_DicomChangeTransferSyntax2(hDS, MAKE_IMAGE_PATH(TEXT("Result.dcm")), UID_EXPLICIT_VR_BIG_ENDIAN, 0, 0, 0); 
   if(nRet != DICOM_SUCCESS) 
   { 
      L_DicomFreeDS(hDS); 
      return nRet; 
   } 
 
   L_DicomFreeDS(hDS); 
   return nRet; 
} 
Help Version 20.0.2019.5.16
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2019 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C API Help