当前位置: 首页>>代码示例>>C#>>正文


C# IByteSource.GetBuffer方法代码示例

本文整理汇总了C#中IByteSource.GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# IByteSource.GetBuffer方法的具体用法?C# IByteSource.GetBuffer怎么用?C# IByteSource.GetBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IByteSource的用法示例。


在下文中一共展示了IByteSource.GetBuffer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseDataset


//.........这里部分代码省略.........
								_vr = DicomVR.SQ;
						}

						_state = ParseState.Value;
					}

					if (_state == ParseState.Value) {
						// check dictionary for VR after reading length to handle 16-bit lengths
						// check before reading value to handle SQ elements
						if (_vr == DicomVR.UN && IsExplicitVR) {
							var entry = Dictionary[_tag];
							if (entry != null)
								_vr = entry.ValueRepresentations.FirstOrDefault();

							if (_vr == null)
								_vr = DicomVR.UN;
						}

						if (_tag == DicomTag.ItemDelimitationItem) {
							// end of sequence item
							return;
						}

						while (_vr == DicomVR.SQ && _tag.IsPrivate) {
							if (!IsPrivateSequence(source)) {
								_vr = DicomVR.UN;
								break;
							}

							if (IsPrivateSequenceBad(source)) {
								_badPrivateSequence = true;
								_explicit = !_explicit;
							}
							break;
						}

						if (_vr == DicomVR.SQ) {
							// start of sequence
							_observer.OnBeginSequence(source, _tag, _length);
							_state = ParseState.Tag;
							if (_length != UndefinedLength) {
								_implicit = false;
								source.PushMilestone(_length);
							} else
								_implicit = true;
							PushState(state);
							ParseItemSequence(source, null);
							continue;
						}

						if (_length == UndefinedLength) {
							_observer.OnBeginFragmentSequence(source, _tag, _vr);
							_state = ParseState.Tag;
							PushState(state);
							ParseFragmentSequence(source, null);
							continue;
						}

						if (!source.Require(_length, ParseDataset, state)) {
							_result = DicomReaderResult.Suspended;
							return;
						}

						IByteBuffer buffer = source.GetBuffer(_length);

						if (!_vr.IsString)
							buffer = EndianByteBuffer.Create(buffer, source.Endian, _vr.UnitSize);
						_observer.OnElement(source, _tag, _vr, buffer);

						// parse private creator value and add to lookup table
						if (_tag.IsPrivate && _tag.Element != 0x0000 && _tag.Element <= 0x00ff) {
							var creator = DicomEncoding.Default.GetString(buffer.Data, 0, buffer.Data.Length).TrimEnd((char)DicomVR.LO.PaddingValue);
							var card = (uint)(_tag.Group << 16) + (uint)(_tag.Element);
							_private[card] = creator;
						}

						ResetState();
					}
				}

				if (source.HasReachedMilestone()) {
					// end of explicit length sequence item
					source.PopMilestone();
					return;
				}

				if (_result != DicomReaderResult.Processing)
					return;

				// end of processing
				_result = DicomReaderResult.Success;
			} catch (Exception e) {
				_exception = e;
				_result = DicomReaderResult.Error;
			} finally {
				if (_result != DicomReaderResult.Processing && _result != DicomReaderResult.Suspended) {
					_async.Set();
				}
			}
		}
开发者ID:peerct,项目名称:fo-dicom,代码行数:101,代码来源:DicomReader.cs

示例2: ParseFragmentSequenceValue

            private bool ParseFragmentSequenceValue(IByteSource source)
            {
                if (this.parseStage == ParseStage.Value)
                {
                    if (!source.Require(this.length))
                    {
                        this.result = DicomReaderResult.Suspended;
                        return false;
                    }

                    var buffer = source.GetBuffer(this.length);
                    buffer = EndianByteBuffer.Create(buffer, source.Endian, this.fragmentItem == 1 ? 4 : this._vr.UnitSize);
                    this.observer.OnFragmentSequenceItem(source, buffer);

                    this.parseStage = ParseStage.Tag;
                }
                return true;
            }
开发者ID:gustavosaita,项目名称:fo-dicom,代码行数:18,代码来源:DicomReader.cs

示例3: ParseFragmentSequence

		private void ParseFragmentSequence(IByteSource source, object state) {
			try {
				_result = DicomReaderResult.Processing;

				while (!source.IsEOF) {
					if (_state == ParseState.Tag) {
						source.Mark();

						if (!source.Require(8, ParseFragmentSequence, state)) {
							_result = DicomReaderResult.Suspended;
							return;
						}

						ushort group = source.GetUInt16();
						ushort element = source.GetUInt16();

						DicomTag tag = new DicomTag(group, element);

						if (tag != DicomTag.Item && tag != DicomTag.SequenceDelimitationItem)
							throw new DicomReaderException("Unexpected tag in DICOM fragment sequence: {0}", tag);

						_length = source.GetUInt32();

						if (tag == DicomTag.SequenceDelimitationItem) {
							// end of fragment
							_observer.OnEndFragmentSequence();
							_fragmentItem = 0;
							ResetState();
							ParseDataset(source, PopState());
							return;
						}

						_fragmentItem++;
						_state = ParseState.Value;
					}

					if (_state == ParseState.Value) {
						if (!source.Require(_length, ParseFragmentSequence, state)) {
							_result = DicomReaderResult.Suspended;
							return;
						}

						IByteBuffer buffer = source.GetBuffer(_length);
						if (_fragmentItem == 1)
							buffer = EndianByteBuffer.Create(buffer, source.Endian, 4);
						else
							buffer = EndianByteBuffer.Create(buffer, source.Endian, _vr.UnitSize);
						_observer.OnFragmentSequenceItem(source, buffer);

						_state = ParseState.Tag;
					}
				}
			} catch (Exception e) {
				_exception = e;
				_result = DicomReaderResult.Error;
			} finally {
				if (_result != DicomReaderResult.Processing && _result != DicomReaderResult.Suspended) {
					_async.Set();
				}
			}
		}
开发者ID:peerct,项目名称:fo-dicom,代码行数:61,代码来源:DicomReader.cs

示例4: ParseValue


//.........这里部分代码省略.........
                        if (!IsPrivateSequence(source))
                        {
                            this._vr = DicomVR.UN;
                            break;
                        }

                        if (IsPrivateSequenceBad(source, this.isExplicitVR))
                        {
                            this.badPrivateSequence = true;
                            this.isExplicitVR = !this.isExplicitVR;
                        }
                        break;
                    }

                    if (this._vr == DicomVR.SQ)
                    {
                        // start of sequence
                        this.observer.OnBeginSequence(source, this._tag, this.length);
                        this.parseStage = ParseStage.Tag;
                        if (this.length != UndefinedLength)
                        {
                            this._implicit = false;
                            source.PushMilestone(this.length);
                        }
                        else
                        {
                            this._implicit = true;
                        }
                        var last = source.Position;

                        // Conformance with CP-246 (#177)
                        var needtoChangeEndian = false;
                        if (parsedVR == DicomVR.UN && !this._tag.IsPrivate)
                        {
                            this._implicit = true;
                            needtoChangeEndian = source.Endian == Endian.Big;
                        }
                        if (needtoChangeEndian)
                        {
                            source.Endian = Endian.Little;
                        }

                        this.ParseItemSequence(source);

                        if (needtoChangeEndian)
                        {
                            source.Endian = Endian.Big;
                        }

                        // Aeric Sylvan - https://github.com/rcd/fo-dicom/issues/62#issuecomment-46248073
                        // Fix reading of SQ with parsed VR of UN
                        if (source.Position > last || this.length == 0)
                        {
                            return true;
                        }

                        this.parseStage = ParseStage.Value;
                        this._vr = parsedVR;
                    }

                    if (this.length == UndefinedLength)
                    {
                        this.observer.OnBeginFragmentSequence(source, this._tag, this._vr);
                        this.parseStage = ParseStage.Tag;
                        this.ParseFragmentSequence(source);
                        return true;
                    }

                    if (!source.Require(this.length))
                    {
                        this.result = DicomReaderResult.Suspended;
                        return false;
                    }

                    var buffer = source.GetBuffer(this.length);

                    if (!this._vr.IsString)
                    {
                        buffer = EndianByteBuffer.Create(buffer, source.Endian, this._vr.UnitSize);
                    }
                    this.observer.OnElement(source, this._tag, this._vr, buffer);

                    // parse private creator value and add to lookup table
                    if (this._tag.IsPrivate && this._tag.Element != 0x0000 && this._tag.Element <= 0x00ff)
                    {
                        var creator =
                            DicomEncoding.Default.GetString(buffer.Data, 0, buffer.Data.Length)
                                .TrimEnd((char)DicomVR.LO.PaddingValue);
                        var card = (uint)(this._tag.Group << 16) + this._tag.Element;

                        lock (this.locker)
                        {
                            this._private[card] = creator;
                        }
                    }

                    this.ResetState();
                }
                return true;
            }
开发者ID:gustavosaita,项目名称:fo-dicom,代码行数:101,代码来源:DicomReader.cs


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