📄 transfersyntax.cs
字号:
/* openDICOM.NET openDICOM# 0.1.1 openDICOM# provides a library for DICOM related development on Mono. Copyright (C) 2006-2007 Albert Gnandt This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA $Id: TransferSyntax.cs 48 2007-03-28 13:49:15Z agnandt $*/using System;using System.Text.RegularExpressions;using openDicom.Registry;using openDicom.DataStructure;using openDicom.DataStructure.DataSet;namespace openDicom.Encoding{ using System.Text; /// <summary> /// This class represents a DICOM transfer syntax. /// </summary> public class TransferSyntax { /// <summary> /// DICOM transfer syntax UID (0002,0010). /// </summary> public static readonly Tag UidTag = new Tag("0002", "0010"); /// <summary> /// DICOM default transfer syntax with UID 1.2.840.10008.1.2. /// </summary> public static readonly TransferSyntax Default = new TransferSyntax(); /// <summary> /// DICOM transfer syntax for file meta information data sets /// (UID is 1.2.840.10008.1.2.1). /// </summary> public static readonly TransferSyntax FileMetaInformation = new TransferSyntax("1.2.840.10008.1.2.1"); private bool isImplicitVR = true; /// <summary> /// Returns whether this transfer syntax instance uses implicit /// DICOM value representations. Implicit VRs can only be accessed /// from the data element dictionary and are not part of a /// DICOM stream. /// </summary> public bool IsImplicitVR { get { return isImplicitVR; } } private bool isLittleEndian = true; /// <summary> /// Returns whether this transfer syntax uses little endian byte /// ordering. This is relevant in context of de-/encoding of /// DICOM stream content according to /// <see cref="IsMachineLittleEndian" />. /// </summary> public bool IsLittleEndian { get { return isLittleEndian; } } /// <summary> /// Returns whether the underlying machine is a little endian /// byte ordering architecture or not. /// </summary> public bool IsMachineLittleEndian { get { return BitConverter.IsLittleEndian; } } private CharacterRepertoire characterRepertoire = CharacterRepertoire.Default; /// <summary> /// Returns the corresponding DICOM character repertoire. /// </summary> public CharacterRepertoire CharacterRepertoire { set { if (value == null) characterRepertoire = CharacterRepertoire.Default; else characterRepertoire = value; } get { return characterRepertoire; } } private Uid uid = new Uid("1.2.840.10008.1.2"); /// <summary> /// Access the DICOM UID indentifying this transfer syntax instance. /// </summary> public Uid Uid { set { if (value != null) { uid = value; if (Regex.IsMatch(uid.ToString(), "^1\\.2\\.840\\.10008\\.1\\.2")) { switch (uid.ToString()) { case "1.2.840.10008.1.2": isImplicitVR = true; isLittleEndian = true; break; case "1.2.840.10008.1.2.1": isImplicitVR = false; isLittleEndian = true; break; case "1.2.840.10008.1.2.2": isImplicitVR = false; isLittleEndian = false; break; case "1.2.840.10008.1.2.99": throw new DicomException("The deflated " + "transfer syntax is not supported.", "uid", uid.ToString()); break; default: // defaults for transfer syntax for JPEG // (1.2.840.10008.1.2.4.*) and RLE // (1.2.840.10008.1.2.5) encoding according // to the DICOM standard isImplicitVR = false; isLittleEndian = true; break; } } else throw new DicomException("UID is not a valid transfer " + "syntax UID.", "TransferSyntax.Uid", uid.ToString()); } else throw new DicomException("UID is null.", "Uid.Uid"); } get { return uid; } } /// <summary> /// Creates a new DICOM default transfer syntax instance with default /// character repertoire. /// </summary> public TransferSyntax() {} /// <summary> /// Creates a new DICOM transfer syntax instance from specified /// DICOM UID string representation and default character repertoire. /// </summary> public TransferSyntax(string uid): this(new Uid(uid), null) {} /// <summary> /// Creates a new DICOM transfer syntax instance from specified /// DICOM UID string representation and specified DICOM character /// repertoire. /// </summary> public TransferSyntax(string uid, CharacterRepertoire characterRepertoire): this(new Uid(uid), characterRepertoire) {} /// <summary> /// Creates a new DICOM transfer syntax instance from specified /// DICOM UID and default character repertoire. /// </summary> public TransferSyntax(Uid uid): this(uid, null) {} /// <summary> /// Creates a new DICOM transfer syntax instance from specified DICOM /// UID and default character repertoire. /// </summary> public TransferSyntax(Uid uid, CharacterRepertoire characterRepertoire) { Uid = uid; CharacterRepertoire = characterRepertoire; } /// <summary> /// Creates a new DICOM transfer syntax instance from specified transfer /// syntax UID data element and default character repertoire. /// </summary> public TransferSyntax(DataElement transferSyntaxUid): this(transferSyntaxUid, null) {} /// <summary> /// Creates a new DICOM transfer syntax instance from specified /// transfer syntax UID data element and specified DICOM character /// repertoire. /// </summary> public TransferSyntax(DataElement transferSyntaxUid, CharacterRepertoire characterRepertoire) { CharacterRepertoire = characterRepertoire; LoadFrom(transferSyntaxUid); } /// <summary> /// Creates a new DICOM transfer syntax instance from specified data
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -