/// <summary> /// Re-creates a data element instance from specified DICOM /// output stream using <see cref="DataElement.TransferSyntax" />. /// </summary> public void LoadFrom(Stream stream) { tag = new Tag(stream, TransferSyntax); vr = ValueRepresentation.LoadFrom(stream, Tag); valueLength = new ValueLength(stream, VR); value = new Value(stream, VR, ValueLength); }
public override int GetHashCode() { var hashCode = 139101280; hashCode = hashCode * -1521134295 + EqualityComparer <TTag> .Default.GetHashCode(Tag); hashCode = hashCode * -1521134295 + ValueLength.GetHashCode(); return(hashCode); }
public override string ToString() { string result = ""; result += "Размер тела атрибута:" + ValueLength.ToString() + "\n"; result += "Смещение тела относительно заголовка:" + ValueOffset.ToString() + "\n"; result += "Резидентные флаги:" + ResidentFlags.ToString() + "\n"; return(result); }
/// <summary> /// /// </summary> /// <returns></returns> public override int GetHashCode() { unchecked { const int hashingBase = (int)2166136261; const int hashingMultiplier = 16777619; var hash = hashingBase; hash = (hash * hashingMultiplier) ^ (!(Name is null) ? Name.GetHashCode() : 0); hash = (hash * hashingMultiplier) ^ (GetType().GetHashCode()); hash = (hash * hashingMultiplier) ^ (!(TextValue is null) ? TextValue.GetHashCode() : 0); hash = (hash * hashingMultiplier) ^ (!(ValueLength is null) ? ValueLength.GetHashCode() : 0); return(hash); } }
/// <summary> /// Determines whether a specified file is an ACR-NEMA file. /// </summary> public static bool IsAcrNemaFile(string fileName) { FileStream fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); bool isStrictDecoded = ValueRepresentation.IsStrictDecoded; ValueRepresentation.IsStrictDecoded = false; try { Tag tag = new Tag(fileStream, TransferSyntax.Default); ValueRepresentation vr = ValueRepresentation.LoadFrom(fileStream, tag); if (vr.IsUndefined) { return(false); } ValueLength valueLength = new ValueLength(fileStream, vr); Value value = null; if (fileStream.Position + valueLength.Value <= fileStream.Length) { value = new Value(fileStream, vr, valueLength); } else { return(false); } return(true); } catch (Exception e) { return(false); } finally { fileStream.Close(); ValueRepresentation.IsStrictDecoded = isStrictDecoded; } }
public virtual void GetBytes(byte[] bytes, ref int startIndex) { CopyBytes(bytes, ref startIndex, ((UInt16)AttributeType).GetBigendianBytes()); CopyBytes(bytes, ref startIndex, ValueLength.GetBigendianBytes()); }