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

C# DicomReadOptions类代码示例

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

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



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

示例1: ButtonLoadFile_Click

        private void ButtonLoadFile_Click(object sender, EventArgs e)
        {
            openFileDialog.DefaultExt = "dcm";
            openFileDialog.ShowDialog();

            DicomFile dicomFile = new DicomFile(openFileDialog.FileName);

            DicomReadOptions options = new DicomReadOptions();

            dicomFile.Load(options);
            


            _theStream.AddFile(dicomFile);

        }
开发者ID:scottshea,项目名称:monodicom,代码行数:16,代码来源:MainDialog.cs


示例2: LoadFiles

        private void LoadFiles(DirectoryInfo dir)
        {
         
            FileInfo[] files = dir.GetFiles();

            foreach (FileInfo file in files)
            {

                DicomFile dicomFile = new DicomFile(file.FullName);

                try
                {

                    DicomReadOptions options = new DicomReadOptions();


                    dicomFile.Load(options);
                    _theStream.AddFile(dicomFile);
                    /*
					if (true == dicomFile.Load())
					{
						_theStream.AddFile(dicomFile);
					}
                     * */
                }
                catch (DicomException) 
                {
                    // TODO:  Add some logging for failed files
                }

            }

            String[] subdirectories = Directory.GetDirectories(dir.FullName);
            foreach (String subPath in subdirectories)
            {
                DirectoryInfo subDir = new DirectoryInfo(subPath);
                LoadFiles(subDir);
                continue;
            }

        }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:41,代码来源:MainDialog.cs


示例3: CreateFrom

		/// <summary>
		/// Creates an instance of <see cref="DicomPixelData"/> from specified image path
		/// </summary>
		/// <param name="path"></param>
		/// <param name="readOptions"></param>
		/// <returns>
		/// </returns>
		public static DicomPixelData CreateFrom(string path, DicomReadOptions readOptions)
		{
			var file = new DicomFile(path);
			file.Load(readOptions);
			return CreateFrom(file);
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:13,代码来源:DicomPixelData.cs


示例4: Load

        /// <summary>
        /// Load a DICOM file (as set by the <see cref="Filename"/> property).
        /// </summary>
        /// <remarks>
        /// Note:  If the file does not contain DICM encoded in it, the routine will assume
        /// the file is not a Part 10 format file, and is instead encoded as just a DataSet
        /// with the transfer syntax set to Implicit VR Little Endian.
        /// </remarks>
        /// <param name="stopTag"></param>
        /// <param name="options">The options to use when reading the file.</param>
		public void Load(DicomTag stopTag, DicomReadOptions options)
        {
        	using (FileStream fs = File.OpenRead(Filename))
        	{
        		Load(fs, stopTag, options);
				fs.Close();
        	}
        }
开发者ID:yjsyyyjszf,项目名称:ClearCanvas-1,代码行数:18,代码来源:DicomFile.cs


示例5: LoadCore

		private void LoadCore(Stream stream, DicomStreamOpener streamOpener, DicomTag stopTag, DicomReadOptions options)
		{
			// TODO CR (24 Jan 2014): DICOM stream read only uses tag value, so the real implementation should be the uint overload!
			if (stopTag == null)
				stopTag = new DicomTag(0xFFFFFFFF, "Bogus Tag", "BogusTag", DicomVr.NONE, false, 1, 1, false);

			DicomStreamReader dsr;

			var iStream = stream ?? streamOpener.Open();
			if (iStream.CanSeek)
			{
				iStream.Seek(128, SeekOrigin.Begin);
				if (!FileHasPart10Header(iStream))
				{
					if (!Flags.IsSet(options, DicomReadOptions.ReadNonPart10Files))
						throw new DicomException(String.Format("File is not part 10 format file: {0}", Filename));

					iStream.Seek(0, SeekOrigin.Begin);
					dsr = new DicomStreamReader(iStream)
					      	{
					      		StreamOpener = streamOpener,
					      		TransferSyntax = TransferSyntax.ImplicitVrLittleEndian,
					      		Dataset = DataSet
					      	};
					DicomReadStatus stat = dsr.Read(stopTag, options);
					if (stat != DicomReadStatus.Success)
					{
						Platform.Log(LogLevel.Error, "Unexpected error when reading file: {0}", Filename);
						throw new DicomException("Unexpected read error with file: " + Filename);
					}

					TransferSyntax = TransferSyntax.ImplicitVrLittleEndian;
					if (DataSet.Contains(DicomTags.SopClassUid))
						MediaStorageSopClassUid = DataSet[DicomTags.SopClassUid].ToString();
					if (DataSet.Contains(DicomTags.SopInstanceUid))
						MediaStorageSopInstanceUid = DataSet[DicomTags.SopInstanceUid].ToString();

					Loaded = true;
					return;
				}
			}
			else
			{
				// TODO CR (04 Apr 2014): this code here is almost identical to the seekable stream above, except that we use the 4CC wrapper
				// we can combine these two when we trust that the wrapper works in all cases
				iStream = FourCcReadStream.Create(iStream);

				// Read the 128 byte header first, then check for DICM
				iStream.SeekEx(128, SeekOrigin.Begin);

				if (!FileHasPart10Header(iStream))
				{
					if (!Flags.IsSet(options, DicomReadOptions.ReadNonPart10Files))
						throw new DicomException(String.Format("File is not part 10 format file: {0}", Filename));

					iStream.Seek(0, SeekOrigin.Begin);
					dsr = new DicomStreamReader(iStream)
					      	{
					      		StreamOpener = streamOpener,
					      		TransferSyntax = TransferSyntax.ImplicitVrLittleEndian,
					      		Dataset = DataSet
					      	};
					DicomReadStatus stat = dsr.Read(stopTag, options);
					if (stat != DicomReadStatus.Success)
					{
						Platform.Log(LogLevel.Error, "Unexpected error when reading file: {0}", Filename);
						throw new DicomException("Unexpected read error with file: " + Filename);
					}

					TransferSyntax = TransferSyntax.ImplicitVrLittleEndian;
					if (DataSet.Contains(DicomTags.SopClassUid))
						MediaStorageSopClassUid = DataSet[DicomTags.SopClassUid].ToString();
					if (DataSet.Contains(DicomTags.SopInstanceUid))
						MediaStorageSopInstanceUid = DataSet[DicomTags.SopInstanceUid].ToString();

					Loaded = true;
					return;
				}
			}

			dsr = new DicomStreamReader(iStream)
			      	{
			      		TransferSyntax = TransferSyntax.ExplicitVrLittleEndian,
			      		StreamOpener = streamOpener,
			      		Dataset = MetaInfo
			      	};

			DicomReadStatus readStat =
				dsr.Read(new DicomTag(0x0002FFFF, "Bogus Tag", "BogusTag", DicomVr.UNvr, false, 1, 1, false), options);
			if (readStat != DicomReadStatus.Success)
			{
				Platform.Log(LogLevel.Error, "Unexpected error when reading file Meta info for file: {0}", Filename);
				throw new DicomException("Unexpected failure reading file Meta info for file: " + Filename);
			}

			MetaInfoFileLength = dsr.EndGroupTwo + 128 + 4;

			dsr.Dataset = DataSet;
			dsr.TransferSyntax = TransferSyntax;
			readStat = dsr.Read(stopTag, options);
//.........这里部分代码省略.........
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:101,代码来源:DicomFile.cs


示例6: Load

		/// <summary>
		/// Load a DICOM file from an input stream, given a delegate to open the stream.
		/// </summary>
		/// <remarks>
		/// Note:  If the file does not contain DICM encoded in it, and 
		/// <see cref="Stream.CanSeek"/> is true for the stream returned by <paramref name="streamOpener"/>, 
		/// the routine will assume the file is not a Part 10 format file, and is 
		/// instead encoded as just a DataSet with the transfer syntax set to 
		/// Implicit VR Little Endian.
		/// 
		/// Also, if you are using the <see cref="DicomReadOptions.StorePixelDataReferences"/> option with
		/// a <see cref="Stream"/> as opposed to simply a file name, you must use this method so that the
		/// stream can be reopenened internally whenever pixel data is accessed.
		/// </remarks>
		/// <param name="streamOpener">A delegate that opens the stream to read from.</param>
		/// <param name="stopTag">The dicom tag to stop the reading at.</param>
		/// <param name="options">The dicom read options to consider.</param>
		public void Load(DicomStreamOpener streamOpener, DicomTag stopTag, DicomReadOptions options)
		{
			Platform.CheckForNullReference(streamOpener, "streamOpener");
			StreamOpener = streamOpener;
			using (var stream = streamOpener.Open())
			{
				LoadCore(stream, streamOpener, stopTag, options);
				stream.Close();
			}
		}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:27,代码来源:DicomFile.cs


示例7: ParseVR

        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;
        }
开发者ID:JeanLedesma,项目名称:mdcm,代码行数:75,代码来源:DicomStreamReader.cs


示例8: Load

		/// <summary>
		/// Loads a dicom file
		/// </summary>
		/// <param name="file">Filename</param>
		/// <param name="options">DICOM read options</param>
		public DicomReadStatus Load(String file, DicomReadOptions options) {
			return Load(file, null, options);
		}
开发者ID:mcmssupereditor,项目名称:mdcm,代码行数:8,代码来源:DicomFileFormat.cs


示例9: Load

 /// <summary>
 /// Loads a dicom file
 /// </summary>
 /// <param name="fs">File stream to read</param>
 /// <param name="options">DICOM read options</param>
 public DicomReadStatus Load(Stream fs, DicomReadOptions options)
 {
     return Load(fs, null, options);
 }
开发者ID:fo-dicom,项目名称:mdcm,代码行数:9,代码来源:DicomFileFormat.cs


示例10: IsSet

 public static bool IsSet(DicomReadOptions options, DicomReadOptions flag)
 {
     return (options & flag) == flag;
 }
开发者ID:jasper-yeh,项目名称:ClearCanvas,代码行数:4,代码来源:Flags.cs


示例11: Read

        public DicomReadStatus Read(DicomTag stopAtTag, DicomReadOptions options)
        {
        	if (stopAtTag == null)
                stopAtTag = new DicomTag(0xFFFFFFFF, "Bogus Tag", "BogusTag", DicomVr.UNvr, false, 1, 1, false);

            // Counters:
            //  _remain - bytes remaining in stream
            //  _bytes - estimates bytes to end of dataset
            //  _read - number of bytes read from stream
            try
            {
                BytesNeeded = 0;
                _remain = _stream.Length - _stream.Position;

                while (_remain > 0)
                {
                    if (_inGroup2 && BytesRead >= _endGroup2)
                    {
                        _inGroup2 = false;
                        // Only change if we're still reading the meta info
                        if (Dataset.StartTagValue < DicomTags.TransferSyntaxUid)
                        {
                            TransferSyntax group2Syntax =
                                TransferSyntax.GetTransferSyntax(
                                    Dataset[DicomTags.TransferSyntaxUid].GetString(0, String.Empty));
                            if (group2Syntax == null)
                                throw new DicomException("Unsupported transfer syntax in group 2 elements");
                            TransferSyntax = group2Syntax;
                        }
                    }
                    uint tagValue;
					if (LastTagRead == null)
					{
						if (_remain < 4)
							return NeedMoreData(4);

						_pos = _stream.Position;
						ushort g = _reader.ReadUInt16();
						ushort e = _reader.ReadUInt16();
						tagValue = DicomTag.GetTagValue(g, e);
						if (DicomTag.IsPrivateGroup(g) && e > 0x00ff)
						{
							SaveTagRead = LastTagRead = DicomTagDictionary.GetDicomTag(g, e) ??
							       new DicomTag((uint) g << 16 | e, "Private Tag", "PrivateTag", DicomVr.UNvr, false, 1, uint.MaxValue, false);
						}
						else
						{
							if (e == 0x0000)
                                SaveTagRead = LastTagRead = new DicomTag((uint)g << 16 | e, "Group Length", "GroupLength", DicomVr.ULvr, false, 1, 1, false);
							else
							{
                                SaveTagRead = LastTagRead = DicomTagDictionary.GetDicomTag(g, e) ??
								       new DicomTag((uint) g << 16 | e, "Private Tag", "PrivateTag", DicomVr.UNvr, false, 1, uint.MaxValue, false);
							}
						}
						_remain -= 4;
						BytesEstimated += 4;
						BytesRead += 4;
					}
					else
						tagValue = LastTagRead.TagValue;

                    if ((tagValue >= stopAtTag.TagValue) 
						&& (_sqrs.Count == 0)) // only exit in root message when after stop tag
                        return DicomReadStatus.Success;

                	bool twoByteLength;
                	if (_vr == null)
                    {
						if (_syntax.ExplicitVr)
						{
							if (LastTagRead == DicomTag.Item ||
								LastTagRead == DicomTag.ItemDelimitationItem ||
								LastTagRead == DicomTag.SequenceDelimitationItem)
							{
								_vr = DicomVr.NONE;
								twoByteLength = _vr.Is16BitLengthField;
							}
							else
							{
								if (_remain < 2)
									return NeedMoreData(2);

								string vr = new string(_reader.ReadChars(2));
								_vr = DicomVr.GetVR(vr);
								twoByteLength = _vr.Is16BitLengthField;
								_remain -= 2;
								BytesEstimated += 2;
								BytesRead += 2;
								if (LastTagRead.VR.Equals(DicomVr.UNvr))
								{
									LastTagRead = new DicomTag(LastTagRead.TagValue, "Private Tag", "PrivateTag", _vr, false, 1, uint.MaxValue, false);
									if (vr.Equals("??"))
										twoByteLength = true;
								}
								else if (!LastTagRead.VR.Equals(_vr))
								{
									if (!vr.Equals("  "))
									{
										DicomTag tag =
//.........这里部分代码省略.........
开发者ID:UIKit0,项目名称:ClearCanvas,代码行数:101,代码来源:StreamReader.cs


示例12: ParseSequenceItemDataset

        private DicomReadStatus ParseSequenceItemDataset(DicomTransferSyntax syntax, long len, out DcmDataset dataset, DicomReadOptions options)
        {
            long pos = _stream.Position;

            dataset = new DcmDataset(pos, (uint)len, syntax);

            Stream stream = (len != UndefinedLength) ? new SegmentStream(_stream, _stream.Position, _len) : _stream;

            DicomStreamReader idsr = new DicomStreamReader(stream);
            idsr.Dataset = dataset;
            idsr.Encoding = _encoding;
            if (len != UndefinedLength)
                idsr.PositionOffset = dataset.StreamPosition;

            DicomReadStatus status = idsr.Read(null, options);

            if (status != DicomReadStatus.Success) {
                _stream.Seek(pos, SeekOrigin.Begin);
                dataset = null;
            }
            else {
                if (len == UndefinedLength) {
                    // rewind delimitation item tag
                    _stream.Seek(-4, SeekOrigin.Current);

                    len = _stream.Position - pos;
                }

                _remain -= len;
                _bytes += len;
                _read += len;
            }

            return status;
        }
开发者ID:JeanLedesma,项目名称:mdcm,代码行数:35,代码来源:DicomStreamReader.cs


示例13: ParseTag

        private DicomReadStatus ParseTag(DicomTag stopAtTag, DicomReadOptions options)
        {
            if (_tag == null) {
                if (_remain >= 4) {
                    _pos = _stream.Position + _offset;
                    ushort g = _reader.ReadUInt16();
                    if (Flags.IsSet(options, DicomReadOptions.FileMetaInfoOnly) && g != 0x0002) {
                        _stream.Seek(-2, SeekOrigin.Current);
                        return DicomReadStatus.SuccessEndRead;
                    }
                    ushort e = _reader.ReadUInt16();
                    if (DicomTag.IsPrivateGroup(g) && e > 0x00ff) {
                        uint card = DicomTag.GetCard(g, e);
                        if ((card & 0xffffff00) != _privateCreatorCard) {
                            _privateCreatorCard = card & 0xffffff00;
                            DicomTag pct = DicomTag.GetPrivateCreatorTag(g, e);
                            DcmDataset ds = _dataset;
                            if (_sds.Count > 0 && _sds.Count == _sqs.Count) {
                                ds = _sds.Peek();
                                if (!ds.Contains(pct))
                                    ds = _dataset;
                            }
                            _privateCreatorId = ds.GetString(pct, String.Empty);
                        }
                        _tag = new DicomTag(g, e, _privateCreatorId);
                    }
                    else {
                        _tag = new DicomTag(g, e);

                        if (g == 0xfffe) {
                            if (_tag == DicomTags.Item ||
                                _tag == DicomTags.ItemDelimitationItem ||
                                _tag == DicomTags.SequenceDelimitationItem)
                                _vr = DicomVR.NONE;
                        }
                    }
                    _remain -= 4;
                    _bytes += 4;
                    _read += 4;
                }
                else {
                    return NeedMoreData(4);
                }
            }

            if (_tag == DicomTags.ItemDelimitationItem && Flags.IsSet(options, DicomReadOptions.SequenceItemOnly))
                return DicomReadStatus.SuccessEndRead;

            if (_tag >= stopAtTag)
                return DicomReadStatus.SuccessEndRead;

            return DicomReadStatus.Success;
        }
开发者ID:JeanLedesma,项目名称:mdcm,代码行数:53,代码来源:DicomStreamReader.cs


示例14: ReadOptionsTest

        public void ReadOptionsTest(DicomFile sourceFile, DicomReadOptions options, bool areEqual)
        {
            bool result = sourceFile.Save(DicomWriteOptions.Default);

            Assert.AreEqual(result, true);

            DicomFile newFile = new DicomFile(sourceFile.Filename);

            newFile.Load(options);

            if (areEqual)
                Assert.AreEqual(sourceFile.DataSet.Equals(newFile.DataSet), true);
            else
                Assert.AreNotEqual(sourceFile.DataSet.Equals(newFile.DataSet), true);
        }
开发者ID:scottshea,项目名称:monodicom,代码行数:15,代码来源:FileTest.cs


示例15: Read

        /// <summary>
        /// Read dataset from stream
        /// </summary>
        /// <param name="stopAtTag">End parsing at this tag</param>
        /// <param name="options">DICOM read options</param>
        /// <returns>Status code</returns>
        public DicomReadStatus Read(DicomTag stopAtTag, DicomReadOptions options)
        {
            // Counters:
            //  _remain - bytes remaining in stream
            //  _bytes - estimates bytes to end of dataset
            //  _read - number of bytes read from stream
            try {
                _need = 0;
                _remain = _stream.Length - _stream.Position;

                while (_remain > 0) {
                    DicomReadStatus status = ParseTag(stopAtTag, options);
                    if (status == DicomReadStatus.SuccessEndRead)
                        return DicomReadStatus.Success;
                    if (status != DicomReadStatus.Success)
                        return status;

                    status = ParseVR(options);
                    if (status != DicomReadStatus.Success)
                        return status;

                    status = ParseLength(options);
                    if (status != DicomReadStatus.Success)
                        return status;

                    if (_tag.IsPrivate) {
                        if (_tag.Element != 0x0000 && _tag.Element <= 0x00ff) {
                            // handle UN private creator id
                            if (_vr != DicomVR.LO && Flags.IsSet(options, DicomReadOptions.ForcePrivateCreatorToLO)) {
                                Dicom.Debug.Log.Warn("Converting Private Creator VR from '{0}' to 'LO'", _vr.VR);
                                _vr = DicomVR.LO;
                            }
                        }
                    }

                    if (_vr == DicomVR.UN && _syntax.IsExplicitVR && Flags.IsSet(options, DicomReadOptions.UseDictionaryForExplicitUN)) {
                        _vr = _tag.Entry.DefaultVR;
                    }

                    if (_fragment != null) {
                        status = InsertFragmentItem(options);
                        if (status != DicomReadStatus.Success)
                            return status;
                    }
                    else if (_sqs.Count > 0 &&
                                (_tag == DicomTags.Item ||
                                 _tag == DicomTags.ItemDelimitationItem ||
                                 _tag == DicomTags.SequenceDelimitationItem)) {
                        status = InsertSequenceItem(options);
                        if (status != DicomReadStatus.Success)
                            return status;
                    }
                    else {
                        if (_sqs.Count > 0) {
                            DcmItemSequence sq = _sqs.Peek();
                            if (sq.StreamLength != UndefinedLength) {
                                long end = sq.StreamPosition + 8 + sq.StreamLength;
                                if (_syntax.IsExplicitVR)
                                    end += 2 + 2;
                                if ((_stream.Position - _offset) >= end) {
                                    if (_sds.Count == _sqs.Count)
                                        _sds.Pop();
                                    _sqs.Pop();
                                }
                            }
                        }

                        if (_len == UndefinedLength) {
                            if (_vr == DicomVR.SQ) {
                                DcmItemSequence sq = new DcmItemSequence(_tag, _pos, _len, _endian);
                                InsertDatasetItem(sq, options);
                                _sqs.Push(sq);
                            }
                            else {
                                _fragment = new DcmFragmentSequence(_tag, _vr, _pos, _endian);
                                InsertDatasetItem(_fragment, options);
                            }
                        }
                        else {
                            if (_vr == DicomVR.SQ) {
                                DcmItemSequence sq = new DcmItemSequence(_tag, _pos, _len, _endian);
                                InsertDatasetItem(sq, options);
                                _sqs.Push(sq);
                            }
                            else {
                                if (_len > _remain)
                                    return NeedMoreData(_len);

                                DcmElement elem = DcmElement.Create(_tag, _vr, _pos, _endian, CurrentBuffer(options));
                                _remain -= _len;
                                _read += _len;

                                InsertDatasetItem(elem, options);
                            }
//.........这里部分代码省略.........
开发者ID:JeanLedesma,项目名称:mdcm,代码行数:101,代码来源:DicomStreamReader.cs


示例16: CurrentBuffer

        private ByteBuffer CurrentBuffer(DicomReadOptions options)
        {
            ByteBuffer bb = null;

            if (_isFile) {
                bool delayLoad = false;
                if (_len >= _largeElementSize && _vr != DicomVR.SQ) {
                    if (Flags.IsSet(options, DicomReadOptions.DeferLoadingLargeElements))
                        delayLoad = true;
                    else if (Flags.IsSet(options, DicomReadOptions.DeferLoadingPixelData) && _tag == DicomTags.PixelData)
                        delayLoad = true;
                    else if (Flags.IsSet(options, DicomReadOptions.DeferLoadingPixelData) && _fragment != null && _fragment.Tag == DicomTags.PixelData)
                        delayLoad = true;
                }

                if (delayLoad) {
                    FileStream fs = (FileStream)_stream;
                    FileSegment segment = new FileSegment(fs.Name, fs.Position, _len);
                    _stream.Seek(_len, SeekOrigin.Current);
                    bb = new ByteBuffer(segment, _endian);
                }
            }

            if (bb == null) {
                bb = new ByteBuffer(_endian);
                bb.CopyFrom(_stream, (int)_len);
            }

            if (_vr.IsEncodedString)
                bb.Encoding = _encoding;

            return bb;
        }
开发者ID:JeanLedesma,项目名称:mdcm,代码行数:33,代码来源:DicomStreamReader.cs


示例17: InsertDatasetItem

        private void InsertDatasetItem(DcmItem item, DicomReadOptions options)
        {
            if (_sds.Count > 0 && _sds.Count == _sqs.Count) {
                DcmDataset ds = _sds.Peek();

                if (_tag.Element == 0x0000) {
                    if (Flags.IsSet(options, DicomReadOptions.KeepGroupLengths))
                        ds.AddItem(item);
                }
                else
                    ds.AddItem(item);

                if (ds.StreamLength != UndefinedLength) {
                    long end = ds.StreamPosition + ds.StreamLength;
                    if ((_stream.Position - _offset) >= end)
                        _sds.Pop();
                }
            }
            else {
                if (_tag.Element == 0x0000) {
                    if (Flags.IsSet(options, DicomReadOptions.KeepGroupLengths))
                        _dataset.AddItem(item);
                }
                else
                    _dataset.AddItem(item);
            }

            if (_tag == DicomTags.SpecificCharacterSet && item is DcmCodeString) {
                DcmCodeString cs = (DcmCodeString)item;
                if (cs.Length > 0) {
                    string[] values = cs.GetValues();
                    for (int i = 0; i < values.Length; i++) {
                        if (String.IsNullOrEmpty(values[i]))
                            continue;
                        _encoding = DcmEncoding.GetEncodingForSpecificCharacterSet(values[i]);
                        break;
                    }
                }
            }
        }
开发者ID:JeanLedesma,项目名称:mdcm,代码行数:40,代码来源:DicomStreamReader.cs


示例18: InsertFragmentItem

        private DicomReadStatus InsertFragmentItem(DicomReadOptions options)
        {
            if (_tag == DicomTags.Item) {
                if (_len > _remain)
                    return NeedMoreData(_len);

                ByteBuffer data = CurrentBuffer(options);
                _remain -= _len;
                _read += _len;

                if (!_fragment.HasOffsetTable)
                    _fragment.SetOffsetTable(data);
                else
                    _fragment.AddFragment(data);
            }
            else if (_tag == DicomTags.SequenceDelimitationItem) {
                _fragment = null;
            }
            else {
                // unexpected tag
                return DicomReadStatus.UnknownError;
            }
            return DicomReadStatus.Success;
        }
开发者ID:JeanLedesma,项目名称:mdcm,代码行数:24,代码来源:DicomStreamReader.cs


示例19: InsertSequenceItem

        private DicomReadStatus InsertSequenceItem(DicomReadOptions options)
        {
            if (_tag.Equals(DicomTags.Item)) {
                if (_len != UndefinedLength && _len > _remain)
                    return NeedMoreData(_len);

                if (_sds.Count > _sqs.Count)
                    _sds.Pop();

                DcmItemSequenceItem si = new DcmItemSequenceItem(_pos, _len);

                if (_len != UndefinedLength || (_stream.CanSeek && Flags.IsSet(options, DicomReadOptions.AllowSeekingForContext))) {
                    if (_len == UndefinedLength)
                        options |= DicomReadOptions.SequenceItemOnly;

                    DcmDataset ds = null;
                    DicomReadStatus status = ParseSequenceItemDataset(TransferSyntax, _len, out ds, options);

                    if (status != DicomReadStatus.Success) {
                        Dicom.Debug.Log.Warn("Unknown error while attempting to read sequence item.  Trying again with alternate encodings.");

                        DicomTransferSyntax[] syntaxes = null;
                        if (TransferSyntax == DicomTransferSyntax.ExplicitVRBigEndian)
                            syntaxes = new DicomTransferSyntax[] { DicomTransferSyntax.ImplicitVRLittleEndian, DicomTransferSyntax.ExplicitVRLittleEndian };
                        else if (TransferSyntax.IsExplicitVR)
                            syntaxes = new DicomTransferSyntax[] { DicomTransferSyntax.ImplicitVRLittleEndian, DicomTransferSyntax.ExplicitVRBigEndian };
                        else
                            syntaxes = new DicomTransferSyntax[] { DicomTransferSyntax.ExplicitVRLittleEndian, DicomTransferSyntax.ExplicitVRBigEndian };

                        foreach (DicomTransferSyntax tx in syntaxes) {
                            status = ParseSequenceItemDataset(tx, _len, out ds, options);
                            if (status == DicomReadStatus.Success)
                                break;
                        }
                    }

                    if (status != DicomReadStatus.Success)
                        return DicomReadStatus.UnknownError;

                    si.Dataset = ds;

                    if (_len == UndefinedLength) {
                        if (8 > _remain) {
                            // need more data?
                            _sds.Push(ds);
                        }
                        else {
                            // skip delimitation item
                            _stream.Seek(8, SeekOrigin.Current);
                            _remain -= 8;
                            _bytes += 8;
                            _read += 8;
                        }
                    }
                }
                else {
                    DcmDataset ds = new DcmDataset(_pos + 8, _len, TransferSyntax);
                    _sds.Push(ds);
                }

                _sqs.Peek().AddSequenceItem(si);
            }
            else if (_tag == DicomTags.ItemDelimitationItem) {
                if (_sds.Count == _sqs.Count)
                    _sds.Pop();
            }
            else if (_tag == DicomTags.SequenceDelimitationItem) {
                if (_sds.Count == _sqs.Count)
                    _sds.Pop();
                _sqs.Pop();
            }
            return DicomReadStatus.Success;
        }
开发者ID:JeanLedesma,项目名称:mdcm,代码行数:73,代码来源:DicomStreamReader.cs


示例20: ParseLength

        private DicomReadStatus ParseLength(DicomReadOptions options)
        {
            if (_len == UndefinedLength) {
                if (_syntax.IsExplicitVR) {
                    if (_tag == DicomTags.Item ||
                        _tag == DicomTags.ItemDelimitationItem ||
                        _tag == DicomTags.SequenceDelimitationItem) {
                        if (_remain >= 4) {
                            _len = _reader.ReadUInt32();
                            _remain -= 4;
                            _bytes += 4;
                            _read += 4;
                        }
                        else {
                            return NeedMoreData(4);
                        }
                    }
                    else {
                        if (_vr.Is16BitLengthField) {
                            if (_remain >= 2) {
                                _len = (uint)_reader.ReadUInt16();
                                _remain -= 2;
                                _bytes += 2;
                                _read += 2;
                            } else {
                                return NeedMoreData(2);
                            }
                        }
                        else {
                            if (_remain >= 6) {
                                _reader.ReadByte();
                                _reader.ReadByte();
                                _len = _reader.ReadUInt32();
                                _remain -= 6;
                                _bytes += 6;
                                _read += 6;
                            }
                            else {
                                return NeedMoreData(6);
                            }
                        }
                    }
                }
                else {
                    if (_remain >= 4) {
                        _len = _reader.ReadUInt32();
                        _remain -= 4;
                        _bytes += 4;
                        _read += 4;
                    }
                    else {
                        return NeedMoreData(4);
                    }
                }

                if (_len != UndefinedLength) {
                    if (_vr != DicomVR.SQ && !(_tag.Equals(DicomTags.Item) && _fragment == null))
                        _bytes += _len;
                }
            }
            return DicomReadStatus.Success;
        }
开发者ID:JeanLedesma,项目名称:mdcm,代码行数:62,代码来源:DicomStreamReader.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# DicomSequenceItem类代码示例发布时间:2022-05-24
下一篇:
C# DicomMessage类代码示例发布时间: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