• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# TransferSyntax类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中TransferSyntax的典型用法代码示例。如果您正苦于以下问题:C# TransferSyntax类的具体用法?C# TransferSyntax怎么用?C# TransferSyntax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TransferSyntax类属于命名空间,在下文中一共展示了TransferSyntax类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ReadFileMetadata

        /// <summary>
        ///     Read explicit VR little endian up to transfer syntax element and determines transfer syntax for rest of elements
        /// </summary>
        /// <param name="dr">the binary reader which is reading the DICOM object</param>
        /// <param name="syntax">the transfer syntax of the DICOM file</param>
        /// <returns>elements preceeding and including transfer syntax element</returns>
        public static List<IDICOMElement> ReadFileMetadata(DICOMBinaryReader dr, ref TransferSyntax syntax)
        {
            var elements = new List<IDICOMElement>();
            syntax = syntax != TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN
                ? syntax
                : TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN;

            while (dr.StreamPosition < dr.StreamLength)
            {
                long position = dr.StreamPosition;
                if (TagReader.ReadLittleEndian(dr).Group == _metaGroup)
                {
                    dr.StreamPosition = position;
                    IDICOMElement el = DICOMElementReader.ReadElementExplicitLittleEndian(dr);
                    Tag uid = TagHelper.TRANSFER_SYNTAX_UID;
                    if (el.Tag == uid)
                    {
                        syntax = TransferSyntaxHelper.GetSyntax(el);
                    }
                    elements.Add(el);
                }
                else
                {
                    dr.StreamPosition = position;
                    break;
                }
            }

            return elements;
        }
开发者ID:waynemunro,项目名称:Evil-DICOM,代码行数:36,代码来源:DICOMFileReader.cs


示例2: ReadFileMetadata

        /// <summary>
        /// Read explicit VR little endian up to transfer syntax element and determines transfer syntax for rest of elements
        /// </summary>
        /// <param name="dr">the binary reader which is reading the DICOM object</param>
        /// <param name="syntax">the transfer syntax of the DICOM file</param>
        /// <returns>elements preceeding and including transfer syntax element</returns>
        private static List<IDICOMElement> ReadFileMetadata(DICOMBinaryReader dr, out TransferSyntax syntax)
        {
            List<IDICOMElement> elements = new List<IDICOMElement>();
            syntax = TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN;

            while (dr.StreamPosition < dr.StreamLength)
            {
                long position = dr.StreamPosition;
                if (TagReader.ReadLittleEndian(dr).Group == _MetaGroup)
                {
                    dr.StreamPosition = position;
                    IDICOMElement el = DICOMElementReader.ReadElementExplicitLittleEndian(dr);
                    if (el.Tag.CompleteID == TagHelper.TRANSFER_SYNTAX_UID.CompleteID)
                    {
                        syntax = TransferSyntaxHelper.GetSyntax(el);
                    }
                    elements.Add(el);
                }
                else
                {
                    dr.StreamPosition = position;
                    break;
                }
            }

            return elements;
        }
开发者ID:baheywadea,项目名称:Evil-DICOM,代码行数:33,代码来源:DICOMFileReader.cs


示例3: LosslessImageTest

	    public static void LosslessImageTest(TransferSyntax syntax, DicomFile theFile)
		{
			if (File.Exists(theFile.Filename))
				File.Delete(theFile.Filename);

			DicomFile saveCopy = new DicomFile(theFile.Filename, theFile.MetaInfo.Copy(), theFile.DataSet.Copy());

			theFile.ChangeTransferSyntax(syntax);

			theFile.Save(DicomWriteOptions.ExplicitLengthSequence);

			DicomFile newFile = new DicomFile(theFile.Filename);

			newFile.Load(DicomReadOptions.Default);

			newFile.ChangeTransferSyntax(saveCopy.TransferSyntax);

			List<DicomAttributeComparisonResult> list = new List<DicomAttributeComparisonResult>();
			bool result = newFile.DataSet.Equals(saveCopy.DataSet, ref list);

			StringBuilder sb = new StringBuilder();
			foreach (DicomAttributeComparisonResult compareResult in list)
				sb.AppendFormat("Comparison Failure: {0}, ", compareResult.Details);

			Assert.IsTrue(result,sb.ToString());
		}
开发者ID:khaha2210,项目名称:radio,代码行数:26,代码来源:AbstractCodecTest.cs


示例4: Main

  public static int Main(string[] args)
    {
    string filename = args[0];
    string outfilename = args[1];

    using( var sfcts = FileChangeTransferSyntax.New() )
      {
      FileChangeTransferSyntax fcts = sfcts.__ref__();
      //SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(fcts, "FileChangeTransferSyntax");
      gdcm.TransferSyntax ts = new TransferSyntax( TransferSyntax.TSType.RLELossless );
      fcts.SetTransferSyntax( ts );
      ImageCodec ic = fcts.GetCodec();
      RLECodec rle = RLECodec.Cast( ic );
      // need to call at least one member func to check not NULL:
      long val = rle.GetBufferLength();
      System.Console.WriteLine( val ); // use val to remove a warning

      fcts.SetInputFileName( filename );
      fcts.SetOutputFileName( outfilename );
      if( !fcts.Change() )
        {
        return 1;
        }
      }

    return 0;
    }
开发者ID:chris-ondemand3d,项目名称:GDCM,代码行数:27,代码来源:FCTS_RLE.cs


示例5: SkipItemLittleEndian

 public static void SkipItemLittleEndian(DICOMBinaryReader dr, TransferSyntax syntax)
 {
     int length = LengthReader.ReadLittleEndian(VR.Null, dr.Skip(4));
     if (length != -1)
     {
         dr.Skip(length);
     }
     else
     {
         if (syntax == TransferSyntax.EXPLICIT_VR_LITTLE_ENDIAN)
         {
             while (!IsEndOfSequenceItemLittleEndian(dr))
             {
                 dr.StreamPosition -= 8;
                 DICOMElementReader.SkipElementExplicitLittleEndian(dr);
             }
         }
         else
         {
             while (!IsEndOfSequenceItemLittleEndian(dr))
             {
                 dr.StreamPosition -= 8;
                 DICOMElementReader.SkipElementImplicitLittleEndian(dr);
             }
         }
     }
 }
开发者ID:DMIAOCHEN,项目名称:Evil-DICOM,代码行数:27,代码来源:SequenceItemReader.cs


示例6: Main

  public static int Main(string[] args)
    {
    string filename = args[0];
    string outfilename = args[1];

    using( var sfcts = FileChangeTransferSyntax.New() )
      {
      FileChangeTransferSyntax fcts = sfcts.__ref__();
      //SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(fcts, "FileChangeTransferSyntax");
      gdcm.TransferSyntax ts = new TransferSyntax( TransferSyntax.TSType.JPEG2000 );
      fcts.SetTransferSyntax( ts );
      ImageCodec ic = fcts.GetCodec();
      JPEG2000Codec jpeg2000 = JPEG2000Codec.Cast( ic );
      jpeg2000.SetReversible( false );
      jpeg2000.SetQuality(0, 55);

      fcts.SetInputFileName( filename );
      fcts.SetOutputFileName( outfilename );
      if( !fcts.Change() )
        {
        return 1;
        }
      }

    return 0;
    }
开发者ID:chris-ondemand3d,项目名称:GDCM,代码行数:26,代码来源:FCTS_JPEG2000.cs


示例7: ChangeSyntax

		public void ChangeSyntax(TransferSyntax syntax)
		{
			try
			{
				if (!_dicomFile.TransferSyntax.Encapsulated)
				{
					// Check if Overlay is embedded in pixels
					OverlayPlaneModuleIod overlayIod = new OverlayPlaneModuleIod(_dicomFile.DataSet);
					for (int i = 0; i < 16; i++)
					{
						if (overlayIod.HasOverlayPlane(i))
						{
							OverlayPlane overlay = overlayIod[i];
							if (overlay.OverlayData == null)
							{
								DicomUncompressedPixelData pd = new DicomUncompressedPixelData(_dicomFile);
								overlay.ConvertEmbeddedOverlay(pd);	
							}
						}
					}
				}
				else if (syntax.Encapsulated)
				{
					// Must decompress first.
					_dicomFile.ChangeTransferSyntax(TransferSyntax.ExplicitVrLittleEndian);
				}

				_dicomFile.ChangeTransferSyntax(syntax);
			}
			catch (Exception e)
			{
				Platform.Log(LogLevel.Error, e, "Unexpected exception compressing/decompressing DICOM file");
			}
		}
开发者ID:nhannd,项目名称:Xian,代码行数:34,代码来源:Compression.cs


示例8: Main

  public static int Main(string[] args)
    {
    string filename = args[0];
    string outfilename = args[1];

    using( var sfcts = FileChangeTransferSyntax.New() )
      {
      FileChangeTransferSyntax fcts = sfcts.__ref__();
      //SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(fcts, "FileChangeTransferSyntax");
      gdcm.TransferSyntax ts = new TransferSyntax( TransferSyntax.TSType.JPEGLSNearLossless );
      fcts.SetTransferSyntax( ts );
      ImageCodec ic = fcts.GetCodec();
      JPEGLSCodec jpegls = JPEGLSCodec.Cast( ic );
      jpegls.SetLossless( false );
      jpegls.SetLossyError( 2 );

      fcts.SetInputFileName( filename );
      fcts.SetOutputFileName( outfilename );
      if( !fcts.Change() )
        {
        return 1;
        }
      }

    return 0;
    }
开发者ID:chris-ondemand3d,项目名称:GDCM,代码行数:26,代码来源:FCTS_JPEGLS.cs


示例9: DicomCompressCommand

		public DicomCompressCommand(DicomMessageBase file, TransferSyntax syntax, IDicomCodec codec, DicomCodecParameters parms)
			: base("DICOM Compress Command", true)
		{

			_file = file;
			_syntax = syntax;
			_codec = codec;
			_parms = parms;
		}
开发者ID:nhannd,项目名称:Xian,代码行数:9,代码来源:DicomCompressCommand.cs


示例10: ReadObject

 public static DICOMObject ReadObject(byte[] objectBytes, TransferSyntax syntax)
 {
     List<IDICOMElement> elements;
     using (DICOMBinaryReader dr = new DICOMBinaryReader(objectBytes))
     {
         elements = DICOMElementReader.ReadAllElements(dr, syntax);
     }
     return new DICOMObject(elements);
 }
开发者ID:baheywadea,项目名称:Evil-DICOM,代码行数:9,代码来源:DICOMObjectReader.cs


示例11: Read

 /// <summary>
 ///     Reads the length from a series of bytes in a stream. The number of bytes is automatically determined from
 ///     VR.
 /// </summary>
 /// <param name="vr">the value representation of the element</param>
 /// <param name="dr">the binary stream with a current position on the length parameter</param>
 /// <param name="syntax">the transfer syntax of this element</param>
 /// <returns></returns>
 public static int Read(VR vr, DICOMBinaryReader dr, TransferSyntax syntax)
 {
     switch (syntax)
     {
         case TransferSyntax.EXPLICIT_VR_BIG_ENDIAN:
             return ReadBigEndian(vr, dr);
         default:
             return ReadLittleEndian(vr, dr);
     }
 }
开发者ID:Baasanjav,项目名称:Evil-DICOM,代码行数:18,代码来源:LengthReader.cs


示例12: DicomPresContext

		internal DicomPresContext(byte pcid, SopClass abstractSyntax, TransferSyntax transferSyntax, DicomPresContextResult result) {
			_pcid = pcid;
			_result = result;
			_roles = DicomRoleSelection.Disabled;
			_abstract = abstractSyntax;
            if (abstractSyntax.Uid.Length == 0)
                throw new DicomException("Invalid abstract syntax for presentation context, UID is zero length.");
            _transfers = new List<TransferSyntax>();
			_transfers.Add(transferSyntax);
		}
开发者ID:nhannd,项目名称:Xian,代码行数:10,代码来源:AssociationParameters.cs


示例13: ReadObject

 public static DICOMObject ReadObject(byte[] objectBytes, TransferSyntax syntax, out long bytesRead)
 {
     List<IDICOMElement> elements;
     using (var dr = new DICOMBinaryReader(objectBytes))
     {
         elements = DICOMElementReader.ReadAllElements(dr, syntax);
         bytesRead = dr.StreamPosition;
     }
     return new DICOMObject(elements);
 }
开发者ID:Baasanjav,项目名称:Evil-DICOM,代码行数:10,代码来源:DICOMObjectReader.cs


示例14: ReadIndefiniteLengthLittleEndian

 public static int ReadIndefiniteLengthLittleEndian(DICOMBinaryReader dr, TransferSyntax syntax)
 {
     long startingPos = dr.StreamPosition;
     while (!IsEndOfSequenceLittleEndian(dr))
     {
         dr.StreamPosition -= 8;
         SequenceItemReader.SkipItemLittleEndian(dr, syntax);
     }
     return CalculateLength(dr, startingPos)-8;
 }
开发者ID:baheywadea,项目名称:Evil-DICOM,代码行数:10,代码来源:SequenceReader.cs


示例15: ReadLittleEndian

 /// <summary>
 ///     Reads the data from an element encoded in little endian byte order
 /// </summary>
 /// <param name="lengthToRead">the length of the data</param>
 /// <param name="dr">the binary reader which is reading the DICOM object</param>
 /// <returns>the data from this element</returns>
 public static byte[] ReadLittleEndian(int lengthToRead, DICOMBinaryReader dr, TransferSyntax syntax)
 {
     if (lengthToRead != -1)
     {
         return dr.ReadBytes(lengthToRead);
     }
     int length = SequenceReader.ReadIndefiniteLengthLittleEndian(dr, syntax);
     byte[] seqBytes = dr.ReadBytes(length);
     dr.Skip(8);
     return seqBytes;
 }
开发者ID:DMIAOCHEN,项目名称:Evil-DICOM,代码行数:17,代码来源:DataReader.cs


示例16: Read

 /// <summary>
 ///     Reads a DICOM file from a byte array
 /// </summary>
 /// <param name="fileBytes">the bytes of the DICOM file</param>
 /// <returns>a DICOM object containing all elements</returns>
 public static DICOMObject Read(byte[] fileBytes, TransferSyntax trySyntax = TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN)
 {
     TransferSyntax syntax = trySyntax; //Will keep if metadata doesn't exist
     List<IDICOMElement> elements;
     using (var dr = new DICOMBinaryReader(fileBytes))
     {
         DICOMPreambleReader.Read(dr);
         List<IDICOMElement> metaElements = ReadFileMetadata(dr, ref syntax);
         elements = metaElements.Concat(DICOMElementReader.ReadAllElements(dr, syntax)).ToList();
     }
     return new DICOMObject(elements);
 }
开发者ID:trunnguyen9,项目名称:COSC-4351,代码行数:17,代码来源:DICOMFileReader.cs


示例17: Read

 /// <summary>
 ///     Reads a DICOM file from a path
 /// </summary>
 /// <param name="stream">the stream to the DICOM file</param>
 /// <returns>a DICOM object containing all elements</returns>
 public static DICOMObject Read(Stream stream, 
     TransferSyntax trySyntax = TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN)
 {
     TransferSyntax syntax = trySyntax;
     List<IDICOMElement> elements;
     using (var dr = new DICOMBinaryReader(stream))
     {
         DICOMPreambleReader.Read(dr);
         List<IDICOMElement> metaElements = ReadFileMetadata(dr, ref syntax);
         elements = metaElements.Concat(DICOMElementReader.ReadAllElements(dr, syntax)).ToList();
     }
     return new DICOMObject(elements);
 }
开发者ID:cureos,项目名称:Evil-DICOM,代码行数:18,代码来源:DICOMFileReader.cs


示例18: ReadBigEndian

        public static DICOMObject ReadBigEndian(DICOMBinaryReader dr, TransferSyntax syntax)
        {
            DICOMObject d;
            int length = LengthReader.ReadLittleEndian(VR.Null, dr.Skip(4));
            if (LengthReader.IsIndefinite(length))
            {
                d = ReadIndefiniteBigEndian(dr, syntax);
            }
            else
            {
                d = DICOMObjectReader.ReadObject(dr.ReadBytes(length), syntax);
            }

            return d;
        }
开发者ID:DMIAOCHEN,项目名称:Evil-DICOM,代码行数:15,代码来源:SequenceItemReader.cs


示例19: ReadAsync

 /// <summary>
 ///     Asynchronously reads a DICOM file from a path
 /// </summary>
 /// <param name="filePath">the path to the DICOM file</param>
 /// <returns>a DICOM object containing all elements</returns>
 public static async Task<DICOMObject> ReadAsync(string filePath,
     TransferSyntax trySyntax = TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN)
 {
     return await Task.Run(() =>
     {
         TransferSyntax syntax = trySyntax;
         List<IDICOMElement> elements;
         using (var dr = new DICOMBinaryReader(filePath))
         {
             DICOMPreambleReader.Read(dr);
             List<IDICOMElement> metaElements = ReadFileMetadata(dr, ref syntax);
             elements = metaElements.Concat(DICOMElementReader.ReadAllElements(dr, syntax)).ToList();
         }
         return new DICOMObject(elements);
     });
 }
开发者ID:rexcardan,项目名称:Evil-DICOM,代码行数:21,代码来源:DICOMFileReader.cs


示例20: TestRegister

		public void TestRegister()
		{
			const string uid = "1.2.3";
			var registered = new TransferSyntax("a", "1.2.3", true, true, true, false, false, true);

			TransferSyntax.RegisterTransferSyntax(registered);
			Assert.IsTrue(TransferSyntax.TransferSyntaxes.Contains(registered));

			var retrieved = TransferSyntax.GetTransferSyntax(uid);
			Assert.AreEqual(uid, retrieved.UidString);

			TransferSyntax.UnregisterTransferSyntax(registered);
			Assert.IsFalse(TransferSyntax.TransferSyntaxes.Contains(registered));

			TransferSyntax.UnregisterTransferSyntax(registered);
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:16,代码来源:TransferSyntaxTests.cs



注:本文中的TransferSyntax类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Transform类代码示例发布时间:2022-05-24
下一篇:
C# TransferMode类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap