public static string DecodeString(string[] specificCharacterSets, string vrs, byte[] bytes) { var dicomStringDecoder = StringDecoder.Get(specificCharacterSets); var vr = DicomVR.Lookup(vrs); return(dicomStringDecoder.Decode(vr, bytes)); }
private DicomReadStatus ParseVR(DicomReadOptions options) { if (_vr == null) { if (_syntax.IsExplicitVR) { if (_remain >= 2) { _vr = DicomVR.Lookup(_reader.ReadChars(2)); _remain -= 2; _bytes += 2; _read += 2; } else { return(NeedMoreData(2)); } } else { if (_tag.Element == 0x0000) { _vr = DicomVR.UL; } else if (Flags.IsSet(options, DicomReadOptions.ForcePrivateCreatorToLO) && _tag.IsPrivate && _tag.Element > 0x0000 && _tag.Element <= 0x00ff) { _vr = DicomVR.UN; } else { _vr = _tag.Entry.DefaultVR; } } if (_vr == DicomVR.UN) { if (_tag.Element == 0x0000) { _vr = DicomVR.UL; // is this needed? } else if (_tag.IsPrivate) { if (_tag.Element <= 0x00ff) { // private creator id } else if (_stream.CanSeek && Flags.IsSet(options, DicomReadOptions.AllowSeekingForContext)) { // attempt to identify private sequence long pos = _stream.Position; if (_syntax.IsExplicitVR) { if (_remain >= 2) { _reader.ReadUInt16(); } else { _vr = null; _stream.Position = pos; return(NeedMoreData(2)); } } uint l = 0; if (_remain >= 4) { l = _reader.ReadUInt32(); if (l == UndefinedLength) { _vr = DicomVR.SQ; } } else { _vr = null; _stream.Position = pos; return(NeedMoreData(4)); } //if (l != 0 && _vr == DicomVR.UN) { // if (_remain >= 4) { // ushort g = _reader.ReadUInt16(); // ushort e = _reader.ReadUInt16(); // DicomTag tag = new DicomTag(g, e); // if (tag == DicomTags.Item || tag == DicomTags.SequenceDelimitationItem) // _vr = DicomVR.SQ; // } else { // _vr = null; // _stream.Position = pos; // return NeedMoreData(4); // } //} _stream.Position = pos; } } } } return(DicomReadStatus.Success); }