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


C# IByteSource.GetUInt8方法代码示例

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


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

示例1: 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

示例2: Decompress

            private IByteSource Decompress(IByteSource source)
            {
                using (var compressed = new MemoryStream())
                {
                    // It is implicitly assumed that the rest of the byte source is compressed.
                    while (!source.IsEOF)
                    {
                        compressed.WriteByte(source.GetUInt8());
                    }

                    compressed.Seek(0, SeekOrigin.Begin);

                    using (var decompressor = new DeflateStream(compressed, CompressionMode.Decompress))
                    {
                        var decompressed = new MemoryStream();
                        decompressor.CopyTo(decompressed);
                        decompressed.Seek(0, SeekOrigin.Begin);
                        return new StreamByteSource(decompressed);
                    }
                }
            }
开发者ID:aerik,项目名称:fo-dicom,代码行数:21,代码来源:DicomReader.cs


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