本文整理汇总了C#中EvilDICOM.Core.IO.Reading.DICOMBinaryReader.Take方法的典型用法代码示例。如果您正苦于以下问题:C# DICOMBinaryReader.Take方法的具体用法?C# DICOMBinaryReader.Take怎么用?C# DICOMBinaryReader.Take使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EvilDICOM.Core.IO.Reading.DICOMBinaryReader
的用法示例。
在下文中一共展示了DICOMBinaryReader.Take方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadLittleEndian
/// <summary>
/// Reads the length in little endian byte format from a series of bytes in a stream
/// </summary>
/// <param name="dr">the binary stream with a current position on the length parameter</param>
/// <param name="length">the number of bytes containing the length</param>
/// <returns>the length</returns>
public static int ReadLittleEndian(DICOMBinaryReader dr, int length)
{
switch (length)
{
case 2:
return BitConverter.ToUInt16(dr.Take(2), 0);
case 4:
return BitConverter.ToInt32(dr.Take(4), 0);
default:
return 0;
}
}
示例2: ReadBigEndian
/// <summary>
/// Reads the length in big endian byte format from a series of bytes in a stream
/// </summary>
/// <param name="dr">the binary stream with a current position on the length parameter</param>
/// <param name="length">the number of bytes containing the length</param>
/// <returns>the length</returns>
public static int ReadBigEndian(DICOMBinaryReader dr, int length)
{
switch (length)
{
case 2:
return BitConverter.ToInt16(dr.Take(2).Reverse().ToArray(), 0);
case 4:
return BitConverter.ToInt32(dr.Take(4).Reverse().ToArray(), 0);
default:
return 0;
}
}
示例3: ReadPDVItem
public static PDVItem ReadPDVItem(DICOMBinaryReader dr)
{
var pi = new PDVItem();
int length = LengthReader.ReadBigEndian(dr, 4);
pi.PresentationContextID = dr.Take(1)[0];
pi.Fragment = ReadPDVFragment(dr, length - 1);
return pi;
}
示例4: ReadPDVFragment
public static PDVItemFragment ReadPDVFragment(DICOMBinaryReader dr, int length)
{
var pif = new PDVItemFragment();
byte messageHeader = dr.Take(1)[0];
pif.IsCommandObject = messageHeader.GetBit(0);
pif.IsLastItem = messageHeader.GetBit(1);
pif.Data = dr.ReadBytes(length - 1);
return pif;
}
示例5: Read
/// <summary>
/// Reads the first 132 bits of a file to check if it contains the DICOM preamble.
/// </summary>
/// <param name="dr">a stream containing the bits of the file</param>
/// <returns>a boolean indicating whether or not the DICOM preamble was in the file</returns>
public static bool Read(DICOMBinaryReader dr)
{
if (dr.StreamLength > 132)
{
byte[] nullPreamble = dr.Take(128);
if (nullPreamble.Any(b => b != 0x00))
{
L.Instance.Log("Missing 132 null byte preamble.", LogPriority.WARNING);
dr.StreamPosition -= 128; //rewind
return false;
}
//READ D I C M
byte[] dcm = dr.Take(4);
if (dcm[0] != 'D' || dcm[1] != 'I' || dcm[2] != 'C' || dcm[3] != 'M')
{
L.Instance.Log("Missing characters D I C M in bits 128-131.", LogPriority.WARNING);
return false;
}
}
return true;
}
示例6: ReadPresentationCtxContents
private static PresentationContext ReadPresentationCtxContents(byte[] contents, bool requestType = false)
{
var pc = new PresentationContext();
pc.TransferSyntaxes = new List<string>();
using (var dr = new DICOMBinaryReader(contents))
{
pc.Id = dr.Take(1)[0];
dr.Skip(1); //Reserved Null Byte
pc.Reason = (PresentationContextReason) Enum.ToObject(typeof (PresentationContextReason), dr.Take(1)[0]);
dr.Skip(1); //Reserved Null Byte
if (requestType)
{
pc.AbstractSyntax = ReadAbstractSyntax(dr).Trim();
}
while (dr.StreamPosition < dr.StreamLength)
{
long initPos = dr.StreamPosition;
pc.TransferSyntaxes.Add(ReadTransferSyntax(dr));
if (dr.StreamPosition == initPos)
{
break;
}
}
}
return pc;
}
示例7: ReadPresentationCtxAccept
public static PresentationContext ReadPresentationCtxAccept(DICOMBinaryReader dr)
{
AssertItemType(dr, "Presentation Context Accept", ItemType.PRESENTATION_CONTEXT_ACCEPT);
dr.Skip(2); // PDU id Reserved Null Byte
int length = LengthReader.ReadBigEndian(dr, 2);
return ReadPresentationCtxContents(dr.Take(length));
}