本文整理汇总了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;
}
示例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);
}
}
}