⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 transfersyntax.cs

📁 Open Dicom source code C#
💻 CS
📖 第 1 页 / 共 2 页
字号:
        ///     set containing a transfer syntax UID data element and default        ///     character repertoire.        /// </summary>        public TransferSyntax(DataSet dataSet): this(dataSet, null) {}        /// <summary>        ///     Creates a new DICOM transfer syntax instance from specified data        ///     set containing a transfer syntax UID data element and specified        ///     character repertoire.        /// </summary>        public TransferSyntax(DataSet dataSet,             CharacterRepertoire characterRepertoire)        {            CharacterRepertoire = characterRepertoire;            LoadFrom(dataSet);        }        /// <summary>        ///     Re-creates a DICOM transfer syntax instance from specified data        ///     set containing a transfer syntax UID data element and default        ///     character repertoire.        /// </summary>        public void LoadFrom(DataSet dataSet)        {            // character repertoire content cannot be read from data set,            // because data set is already read in.            if (dataSet.Contains(UidTag))                LoadFrom(dataSet[UidTag]);            else                throw new DicomException("Data set does not contain a " +                    "transfer syntax UID.", "dataSet");        }        /// <summary>        ///     Determines whether this instance is equal to another DICOM        ///     transfer syntax instance or not. Equality of the UIDs will        ///     be checked.        /// </summary>        public void LoadFrom(DataElement transferSyntaxUid)        {            if (transferSyntaxUid != null)            {                if (transferSyntaxUid.Tag.Equals(UidTag))                    Uid = (Uid) transferSyntaxUid.Value[0];                else                    throw new DicomException("Data element is not a transfer " +                        "syntax UID.", "transferSyntaxUID.Tag",                         transferSyntaxUid.Tag.ToString());            }            else                throw new DicomException("Data element is null.",                     "transferSyntaxUID");                                }        /// <summary>        ///     Determines whether this instance is equal to another DICOM        ///     transfer syntax instance or not. Equality of the UIDs will        ///     be checked.        /// </summary>        public bool Equals(TransferSyntax transferSyntax)        {            if (transferSyntax != null)                return Uid.Equals(transferSyntax.Uid);            else                return false;        }        /// <summary>        ///     Converts an array of bytes into a string by this        ///     DICOM transfer syntax instance's character repertoire.        /// </summary>        public string ToString(byte[] bytes)        {            return ByteConvert.ToString(bytes, CharacterRepertoire);        }        /// <summary>        ///     Converts count of bytes from a byte array into a string by this        ///     DICOM transfer syntax instance's character repertoire.        /// </summary>        public string ToString(byte[] bytes, int count)        {            return ByteConvert.ToString(bytes, count, CharacterRepertoire);        }        /// <summary>        ///     Converts count of bytes from a byte array starting at         ///     specified offset into a string by this DICOM transfer syntax        ///     instance's character repertoire.        /// </summary>        public virtual string ToString(byte[] bytes, int offset, int count)        {            return ByteConvert.ToString(bytes, offset, count,                 CharacterRepertoire);        }        /// <summary>        ///     Converts a string into an array of bytes by this        ///     DICOM transfer syntax instance's character repertoire.        /// </summary>        public virtual byte[] ToBytes(string s)        {            return ByteConvert.ToBytes(s, CharacterRepertoire);        }        /// <summary>        ///     Determines whether the bytes of an unsigned word have to be        ///     swapped according to the used transfer syntax. There is        ///     considered the endian type of underlying machine and transfer        ///     syntax.        /// </summary>        /// <param name="word">        ///     Unsigned word to process.        /// </param>        /// <returns>        ///     Unsigned word with or without bytes swapped.        /// </returns>        public ushort CorrectByteOrdering(ushort word)        {            if ((IsMachineLittleEndian && ! IsLittleEndian) ||                ( ! IsMachineLittleEndian && IsLittleEndian))                return ByteConvert.SwapBytes(word);            else                return word;        }        /// <summary>        ///     Determines whether the bytes of a signed word have to be        ///     swapped according to the used transfer syntax. There is        ///     considered the endian type of underlying machine and transfer        ///     syntax.        /// </summary>        /// <param name="word">        ///     Signed word to process.        /// </param>        /// <returns>        ///     Signed word with or without bytes swapped.        /// </returns>        public short CorrectByteOrdering(short word)        {            if ((IsMachineLittleEndian && ! IsLittleEndian) ||                ( ! IsMachineLittleEndian && IsLittleEndian))                return ByteConvert.SwapBytes(word);            else                return word;        }        /// <summary>        ///     Determines whether the bytes of an unsigned integer have to be        ///     swapped according to the used transfer syntax. There is        ///     considered the endian type of underlying machine and transfer        ///     syntax.        /// </summary>        /// <param name="value">        ///     Unsigned integer to process.        /// </param>        /// <returns>        ///     Unsigned integer with or without bytes swapped.        /// </returns>        public uint CorrectByteOrdering(uint value)        {            if ((IsMachineLittleEndian && ! IsLittleEndian) ||                ( ! IsMachineLittleEndian && IsLittleEndian))                return ByteConvert.SwapBytes(value);            else                return value;        }        /// <summary>        ///     Determines whether the bytes of a signed integer have to be        ///     swapped according to the used transfer syntax. There is        ///     considered the endian type of underlying machine and transfer        ///     syntax.        /// </summary>        /// <param name="value">        ///     Signed integer to process.        /// </param>        /// <returns>        ///     Signed integer with or without bytes swapped.        /// </returns>        public int CorrectByteOrdering(int value)        {            if ((IsMachineLittleEndian && ! IsLittleEndian) ||                ( ! IsMachineLittleEndian && IsLittleEndian))                return ByteConvert.SwapBytes(value);            else                return value;        }        /// <summary>        ///     Determines whether the bytes of an array have to be swapped        ///     according to the used transfer syntax. This method only is        ///     relevant to numeric representations as byte arrays. There is        ///     considered the endian type of underlying machine and transfer        ///     syntax.        /// </summary>        /// <param name="bytes">        ///     Byte array to process.        /// </param>        /// <returns>        ///     Byte array with or without bytes swapped.        /// </returns>        public byte[] CorrectByteOrdering(byte[] bytes)        {            if ((IsMachineLittleEndian && ! IsLittleEndian) ||                ( ! IsMachineLittleEndian && IsLittleEndian))                return ByteConvert.SwapBytes(bytes);            else                return bytes;        }        /// <summary>        ///     Returns a DICOM transfer syntax UID as string representation.        /// </summary>        public override string ToString()        {            return Uid.ToString();        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -