←Select platform

ChangeTransferSyntax(string,string,int,ChangeTransferSyntaxFlags,DicomDataSetSaveFlags) Method

Changes the Transfer Syntax of the Data Set, and saves resulting DicomDataSet to a file.
public void ChangeTransferSyntax( 
   string outFile, 
   string uid, 
   int qualityFactor, 
   ChangeTransferSyntaxFlags flags, 
   DicomDataSetSaveFlags saveFlags 
void ChangeTransferSyntax(  
   String^ outFile, 
   String^ uid, 
   int qualityFactor, 
   ChangeTransferSyntaxFlags flags, 
   DicomDataSetSaveFlags saveFlags 


Character string that contains the name of the output file.

Character string that contains the UID of the new Transfer Syntax. For possible values, refer to Transfer Syntax Values.

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.

Indicates how the compression will be performed.

Flags that indicate the file characteristics to use when saving the file.


This method will convert the DicomDataSet Transfer Syntax to the Transfer Syntax specified in [uid](" id="uidparameterlink" class="popuplink.html), maintaining all elements and values in the DicomDataSet. Additionally, the resulting DicomDataSet is saved as a file outFile using the characteristics specified by saveFlags.

This method does everything the function to ChangeTransferSyntax does, but additionally saves a DicomDataSet with the new transfer syntax at the location outFile with save options specified by saveFlags. Note that this overload should be used when trying to produce a file with the new transfer syntax, as opposed to the ChangeTransferSyntax overload followed by calling Save. Using this overload that produces a file directly will be significantly faster and use fewer resources (memory and disk), especially for large files.

Only the following DicomDataSetSaveFlags flags affect how the DicomDataSet is saved to disk.

The following DicomDataSetSaveFlags flags are ignored, and have no effect with how DicomDataSet is saved to disk. These flags are ignored because the transfer syntax specified by [uid](" id="uidparameterlink" class="popuplink.html) determines little endian versus big endian, as implicit VR versus explicit VR.

Passing null for outFile if you do not want to save the result as a file. In this case, the saveFlags are ignored. This is functionally equivalent to using the ChangeTransferSyntax overload .

For more details about changing the transfer syntax, see ChangeTransferSyntax.


This example will change the trasfer syntax of a DicomDataSet and save the result as a file.

using Leadtools; 
using Leadtools.Dicom; 
public void Test_DicomDataSet_ChangeTransferSyntaxSample() 
   string dicomFileName = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image2.dcm"); 
   string dicomResultFileHame = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "Result.dcm"); 
   using (DicomDataSet ds = new DicomDataSet()) 
      ds.Load(dicomFileName, DicomDataSetLoadFlags.None); 
      ds.ChangeTransferSyntax(dicomResultFileHame, DicomUidType.ExplicitVRBigEndian, 0, ChangeTransferSyntaxFlags.None, DicomDataSetSaveFlags.None); 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Dicom Assembly