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


C# IByteSource.Skip方法代码示例

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


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

示例1: ParseDataset


//.........这里部分代码省略.........
						if (_tag.IsPrivate) {
							if (_tag.Element != 0x0000 && _tag.Element <= 0x00ff && _vr == DicomVR.UN)
								_vr = DicomVR.LO; // force private creator to LO
						}
					}

					while (_state == ParseState.Length) {
						if (_tag == DicomTag.Item || _tag == DicomTag.ItemDelimitationItem || _tag == DicomTag.SequenceDelimitationItem) {
							if (!source.Require(4, ParseDataset, state)) {
								_result = DicomReaderResult.Suspended;
								return;
							}

							_length = source.GetUInt32();

							_state = ParseState.Value;
							break;
						}

						if (IsExplicitVR) {
							if (_vr.Is16bitLength) {
								if (!source.Require(2, ParseDataset, state)) {
									_result = DicomReaderResult.Suspended;
									return;
								}

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

								source.Skip(2);
								_length = source.GetUInt32();
							}
						} else {
							if (!source.Require(4, ParseDataset, state)) {
								_result = DicomReaderResult.Suspended;
								return;
							}

							_length = source.GetUInt32();

							// assume that undefined length in implicit dataset is SQ
							if (_length == UndefinedLength && _vr == DicomVR.UN)
								_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
开发者ID:peerct,项目名称:fo-dicom,代码行数:67,代码来源:DicomReader.cs

示例2: Preprocess

        private static void Preprocess(
            IByteSource source,
            ref DicomFileFormat fileFormat,
            ref DicomTransferSyntax syntax)
        {
            // mark file origin
            source.Mark();

            // test for DICM preamble
            source.Skip(128);
            if (source.GetUInt8() == 'D' && source.GetUInt8() == 'I' && source.GetUInt8() == 'C'
                && source.GetUInt8() == 'M')
            {
                fileFormat = DicomFileFormat.DICOM3;
            }

            // test for incorrect syntax in file meta info
            do
            {
                if (fileFormat == DicomFileFormat.DICOM3)
                {
                    // move milestone to after preamble
                    source.Mark();
                }
                else
                {
                    // rewind to origin milestone
                    source.Rewind();
                }

                // test for file meta info
                var group = source.GetUInt16();

                if (@group > 0x00ff)
                {
                    source.Endian = Endian.Big;
                    syntax = DicomTransferSyntax.ExplicitVRBigEndian;

                    @group = Endian.Swap(@group);
                }

                if (@group > 0x00ff)
                {
                    // invalid starting tag
                    fileFormat = DicomFileFormat.Unknown;
                    source.Rewind();
                    break;
                }

                if (fileFormat == DicomFileFormat.Unknown)
                {
                    fileFormat = @group == 0x0002
                                     ? DicomFileFormat.DICOM3NoPreamble
                                     : DicomFileFormat.DICOM3NoFileMetaInfo;
                }

                var element = source.GetUInt16();
                var tag = new DicomTag(@group, element);

                // test for explicit VR
                var vrt = Encoding.UTF8.GetBytes(tag.DictionaryEntry.ValueRepresentations[0].Code);
                var vrs = source.GetBytes(2);

                if (vrt[0] != vrs[0] || vrt[1] != vrs[1])
                {
                    // implicit VR
                    syntax = syntax.Endian == Endian.Little
                                 ? DicomTransferSyntax.ImplicitVRLittleEndian
                                 : DicomTransferSyntax.ImplicitVRBigEndian;
                }

                source.Rewind();
            }
            while (fileFormat == DicomFileFormat.Unknown);

            if (fileFormat == DicomFileFormat.Unknown)
            {
                throw new DicomReaderException("Attempted to read invalid DICOM file");
            }

            // Adopt transfer syntax endianess to byte source.
            source.Endian = syntax.Endian;
        }
开发者ID:aerik,项目名称:fo-dicom,代码行数:83,代码来源:DicomFileReader.cs

示例3: ParseLength

            private bool ParseLength(IByteSource source)
            {
                while (this.parseStage == ParseStage.Length)
                {
                    if (this._tag == DicomTag.Item || this._tag == DicomTag.ItemDelimitationItem
                        || this._tag == DicomTag.SequenceDelimitationItem)
                    {
                        if (!source.Require(4))
                        {
                            this.result = DicomReaderResult.Suspended;
                            return false;
                        }

                        this.length = source.GetUInt32();

                        this.parseStage = ParseStage.Value;
                        break;
                    }

                    if (this.isExplicitVR)
                    {
                        if (this._vr == DicomVR.Implicit)
                        {
                            if (!source.Require(4))
                            {
                                this.result = DicomReaderResult.Suspended;
                                return false;
                            }

                            this.length = source.GetUInt32();

                            // assume that undefined length in implicit VR element is SQ
                            if (this.length == UndefinedLength)
                            {
                                this._vr = DicomVR.SQ;
                            }
                        }
                        else if (this._vr.Is16bitLength)
                        {
                            if (!source.Require(2))
                            {
                                this.result = DicomReaderResult.Suspended;
                                return false;
                            }

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

                            source.Skip(2);
                            this.length = source.GetUInt32();

                            // CP-246 (#177) handling
                            // assume that Undefined Length in explicit datasets with VR UN are sequences 
                            // According to CP-246 the sequence shall be handled as ILE, but this will be handled later...
                            // in the current code this needs to be restricted to privates 
                            if (this.length == UndefinedLength && this._vr == DicomVR.UN && this._tag.IsPrivate)
                            {
                                this._vr = DicomVR.SQ;
                            }
                        }
                    }
                    else
                    {
                        if (!source.Require(4))
                        {
                            this.result = DicomReaderResult.Suspended;
                            return false;
                        }

                        this.length = source.GetUInt32();

                        // assume that undefined length in implicit dataset is SQ
                        if (this.length == UndefinedLength && this._vr == DicomVR.UN)
                        {
                            this._vr = DicomVR.SQ;
                        }
                    }

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

示例4: autoCheckTransferSyntax

        private void autoCheckTransferSyntax(IByteSource source, ushort group, ushort element, object state)
        {
            //start checking Transfer Syntax after reading premable bytes
            if (group > 0x0002 && !bAutoDetectVRType)
            {
                bAutoDetectVRType = true;//just check once
                source.Mark();//mark the original position of pointer
                //try to parse VR
                uint tmpLength = 0;
                source.Skip(2);
                if (!source.Require(2, ParseDataset, state))
                {
                    _result = DicomReaderResult.Suspended;
                    source.Rewind();
                    return;
                }
                tmpLength = source.GetUInt16();
                try
                {
                    if (!source.Require(tmpLength, ParseDataset, state))
                    {
                        _result = DicomReaderResult.Suspended;
                        source.Rewind();
                        return;
                    }
                    source.Skip((int)tmpLength);
                    if (!source.Require(4, ParseDataset, state))
                    {
                        _result = DicomReaderResult.Suspended;
                        source.Rewind();
                        return;
                    }
                    ushort group2 = source.GetUInt16();
                    ushort element2 = source.GetUInt16();
                    DicomPrivateCreator creator2 = null;
                    if (group2.IsOdd() && element2 > 0x00ff)
                    {
                        string pvt2 = null;
                        uint card2 = (uint)(group2 << 16) + (uint)(element2 >> 8);
                        if (_private.TryGetValue(card2, out pvt2))
                            creator2 = Dictionary.GetPrivateCreator(pvt2);
                    }
                    var tmpTag = new DicomTag(group2, element2, creator2);
                    var tmpEntry = Dictionary[tmpTag];

                    if (!tmpTag.IsPrivate && tmpEntry != null && tmpEntry.MaskTag == null)
                    {
                        tmpTag = tmpEntry.Tag; // Use dictionary tag
                        IsExplicitVR = true;
                    }
                    else
                    {
                        IsExplicitVR = false;
                    }
                    source.Rewind();
                }
                catch (Exception exin)
                {
                    source.Rewind();
                    //说明有错误,直接抛出异常
                    throw new DicomIoException("Auto Check Transfer Syntax Exception by zssure,Details:{0}", exin.StackTrace);

                }


            }

        }
开发者ID:ZeryZhang,项目名称:fo-dicom,代码行数:68,代码来源:DicomReader.cs


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