←Select platform

ChangeTransferSyntax(string,int,ChangeTransferSyntaxFlags) Method

Changes the Transfer Syntax of the Data Set.
public void ChangeTransferSyntax( 
   string uid, 
   int qualityFactor, 
   ChangeTransferSyntaxFlags flags 
public void changeTransferSyntax(String uid, int qualityFactor, int changeTransferSyntaxFlags) 
void ChangeTransferSyntax(  
   String^ uid, 
   int qualityFactor, 
   ChangeTransferSyntaxFlags flags 


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.


This method will convert the Data Set's Transfer Syntax to the Transfer Syntax specified in uid, maintaining all elements and values in the Data Set. After this method is called all previous references to data elements in the Data Set will no longer be valid.

This method is especially useful when sending a C-Store Request message using the SendCStoreRequest method. The user can match the Data Set Transfer Syntax with the Transfer Syntax of the SCP.

If this function throws an "Error writing to a file" exception one of the causes could be that your system is missing the LEADTOOLS file filter Leadtools.Codecs.Cmp.dll. Specifically, this error will be returned if either the original transfer syntax or the new transfer syntax is one of the following:

  • JPEGBaseline1
  • JPEGExtended2_4
  • JPEGLosslessNonhier14
  • JPEGLosslessNonhier14B

Make sure that the Leadtools.Codecs.Cmp.dll is in the same folder as the other LEAD DLLS. For more information see Files To Be Included With Your Application Note: This method 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 Module.

using Leadtools; 
using Leadtools.Dicom; 
public void TestChangeTransferSyntax() 
   string dicomFileName = Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "image3.dcm"); 
   //Make sure to initialize the DICOM engine, this needs to be done only once  
   //In the whole application 
   using (DicomDataSet ds = new DicomDataSet()) 
      //Load DICOM File 
      ds.Load(dicomFileName, DicomDataSetLoadFlags.None); 
      DicomJpeg2000Options options = ds.DefaultJpeg2000Options; 
      Console.WriteLine("JPEG 2000 Options:"); 
      Console.WriteLine("DicomJpeg2000Options.UseColorTransform            is : {0}", options.UseColorTransform); 
      Console.WriteLine("DicomJpeg2000Options.DerivedQuantization          is : {0}", options.DerivedQuantization); 
      Console.WriteLine("DicomJpeg2000Options.TargetFileSize               is : {0}", options.TargetFileSize); 
      Console.WriteLine("DicomJpeg2000Options.ImageAreaHorizontalOffset    is : {0}", options.ImageAreaHorizontalOffset); 
      Console.WriteLine("DicomJpeg2000Options.ImageAreaVerticalOffset      is : {0}", options.ImageAreaVerticalOffset); 
      Console.WriteLine("DicomJpeg2000Options.ReferenceTileWidth           is : {0}", options.ReferenceTileWidth); 
      Console.WriteLine("DicomJpeg2000Options.ReferenceTileHeight          is : {0}", options.ReferenceTileHeight); 
      Console.WriteLine("DicomJpeg2000Options.TileHorizontalOffset         is : {0}", options.TileHorizontalOffset); 
      Console.WriteLine("DicomJpeg2000Options.TileVerticalOffset           is : {0}", options.TileVerticalOffset); 
      Console.WriteLine("DicomJpeg2000Options.DecompositionLevels          is : {0}", options.DecompositionLevels); 
      Console.WriteLine("DicomJpeg2000Options.ProgressingOrder             is : {0}", options.ProgressingOrder); 
      Console.WriteLine("DicomJpeg2000Options.UseSopMarker                 is : {0}", options.UseSopMarker); 
      Console.WriteLine("DicomJpeg2000Options.UseEphMarker                 is : {0}", options.UseEphMarker); 
      Console.WriteLine("DicomJpeg2000Options.RegionOfInterest             is : {0}", options.RegionOfInterest); 
      Console.WriteLine("DicomJpeg2000Options.UseRegionOfInterest          is : {0}", options.UseRegionOfInterest); 
      Console.WriteLine("DicomJpeg2000Options.RegionOfInterestWeight       is : {0}", options.RegionOfInterestWeight); 
      Console.WriteLine("DicomJpeg2000Options.RegionOfInterestRectangle    is : {0}", options.RegionOfInterestRectangle); 
      options.CompressionControl = DicomJpeg2000CompressionControl.Ratio; 
      options.CompressionRatio = 50; 
      Console.WriteLine("Changed CompressionControl to DicomJpeg2000CompressionControl.Ratio and DicomJpeg2000CompressionControl.CompressionRatio to 50"); 
      ds.Jpeg2000Options = options; 
      ds.ChangeTransferSyntax(DicomUidType.JPEG2000, 2, ChangeTransferSyntaxFlags.None); 
      ds.Save(Path.Combine(LEAD_VARS.ImagesDir, "DICOM", "DicomJ2K.dcm"), 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