本文整理汇总了C#中EvilDICOM.Core.IO.Reading.DICOMBinaryReader类的典型用法代码示例。如果您正苦于以下问题:C# DICOMBinaryReader类的具体用法?C# DICOMBinaryReader怎么用?C# DICOMBinaryReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DICOMBinaryReader类属于EvilDICOM.Core.IO.Reading命名空间,在下文中一共展示了DICOMBinaryReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadFileMetadata
/// <summary>
/// Read explicit VR little endian up to transfer syntax element and determines transfer syntax for rest of elements
/// </summary>
/// <param name="dr">the binary reader which is reading the DICOM object</param>
/// <param name="syntax">the transfer syntax of the DICOM file</param>
/// <returns>elements preceeding and including transfer syntax element</returns>
private static List<IDICOMElement> ReadFileMetadata(DICOMBinaryReader dr, out TransferSyntax syntax)
{
List<IDICOMElement> elements = new List<IDICOMElement>();
syntax = TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN;
while (dr.StreamPosition < dr.StreamLength)
{
long position = dr.StreamPosition;
if (TagReader.ReadLittleEndian(dr).Group == _MetaGroup)
{
dr.StreamPosition = position;
IDICOMElement el = DICOMElementReader.ReadElementExplicitLittleEndian(dr);
if (el.Tag.CompleteID == TagHelper.TRANSFER_SYNTAX_UID.CompleteID)
{
syntax = TransferSyntaxHelper.GetSyntax(el);
}
elements.Add(el);
}
else
{
dr.StreamPosition = position;
break;
}
}
return elements;
}
示例2: PeekVR
public static VR PeekVR(DICOMBinaryReader dr)
{
byte[] vrBytes = dr.Peek(2);
char[] vr = Encoding.UTF8.GetChars(vrBytes);
VR foundVR = VRDictionary.GetVRFromAbbreviation(new string(vr));
return foundVR;
}
示例3: ReadFileMetadata
/// <summary>
/// Read explicit VR little endian up to transfer syntax element and determines transfer syntax for rest of elements
/// </summary>
/// <param name="dr">the binary reader which is reading the DICOM object</param>
/// <param name="syntax">the transfer syntax of the DICOM file</param>
/// <returns>elements preceeding and including transfer syntax element</returns>
public static List<IDICOMElement> ReadFileMetadata(DICOMBinaryReader dr, ref TransferSyntax syntax)
{
var elements = new List<IDICOMElement>();
syntax = syntax != TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN
? syntax
: TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN;
while (dr.StreamPosition < dr.StreamLength)
{
long position = dr.StreamPosition;
if (TagReader.ReadLittleEndian(dr).Group == _metaGroup)
{
dr.StreamPosition = position;
IDICOMElement el = DICOMElementReader.ReadElementExplicitLittleEndian(dr);
Tag uid = TagHelper.TRANSFER_SYNTAX_UID;
if (el.Tag == uid)
{
syntax = TransferSyntaxHelper.GetSyntax(el);
}
elements.Add(el);
}
else
{
dr.StreamPosition = position;
break;
}
}
return elements;
}
示例4: ReadUIDItem
private static string ReadUIDItem(DICOMBinaryReader dr, string itemName, ItemType iType)
{
AssertItemType(dr, itemName, iType);
dr.Skip(2); // PDU ID and Reserved Null Byte
int length = LengthReader.ReadBigEndian(dr, 2);
return dr.ReadString(length).Trim();
}
示例5: WriteDecimalString
public void WriteDecimalString()
{
var ds = new DecimalString();
ds.DData_ = Enumerable.Range(1, 15000).Select(i => ((double)i) + 0.005).ToList();
ds.Tag = new Tag("00082130");
byte[] written;
var settings = DICOMWriteSettings.Default();
using (var ms = new MemoryStream())
{
using (var dw = new DICOMBinaryWriter(ms))
{
DICOMElementWriter.Write(dw, DICOMWriteSettings.Default(), ds);
}
written = ms.ToArray();
}
using (var dr = new DICOMBinaryReader(written))
{
var read = DICOMElementReader.ReadElementImplicitLittleEndian(dr) as DecimalString;
CollectionAssert.AreEqual(ds.DData_, read.Data_);
}
}
示例6: SkipItemLittleEndian
public static void SkipItemLittleEndian(DICOMBinaryReader dr, TransferSyntax syntax)
{
int length = LengthReader.ReadLittleEndian(VR.Null, dr.Skip(4));
if (length != -1)
{
dr.Skip(length);
}
else
{
if (syntax == TransferSyntax.EXPLICIT_VR_LITTLE_ENDIAN)
{
while (!IsEndOfSequenceItemLittleEndian(dr))
{
dr.StreamPosition -= 8;
DICOMElementReader.SkipElementExplicitLittleEndian(dr);
}
}
else
{
while (!IsEndOfSequenceItemLittleEndian(dr))
{
dr.StreamPosition -= 8;
DICOMElementReader.SkipElementImplicitLittleEndian(dr);
}
}
}
}
示例7: ReadPresentationCtxRequest
public static PresentationContext ReadPresentationCtxRequest(DICOMBinaryReader dr)
{
AssertItemType(dr, "Presentation Context Request", ItemType.PRESENTATION_CONTEXT_REQUEST);
dr.Skip(2); // PDU id Reserved Null Byte
int length = LengthReader.ReadBigEndian(dr, 2);
return ReadPresentationCtxContents(dr.Take(length), true);
}
示例8: ReadMaxLength
public static int? ReadMaxLength(DICOMBinaryReader dr)
{
AssertItemType(dr, "Maximum Length", ItemType.MAXIMUM_LENGTH);
dr.Skip(2); // PDU ID and Reserved Null Byte
int length = LengthReader.ReadBigEndian(dr, 2);
return LengthReader.ReadBigEndian(dr, 4);
}
示例9: 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;
}
示例10: ReadElementExplicitBigEndian
/// <summary>
/// Reads and returns the next DICOM element starting at the current location in the DICOM binary reader
/// </summary>
/// <param name="dr">the binary reader which is reading the DICOM object</param>
/// <returns>the next DICOM element</returns>
public static IDICOMElement ReadElementExplicitBigEndian(DICOMBinaryReader dr)
{
Tag tag = TagReader.ReadBigEndian(dr);
VR vr = VRReader.Read(dr);
int length = LengthReader.ReadBigEndian(vr, dr);
byte[] data = DataReader.ReadBigEndian(length, dr);
return ElementFactory.GenerateElement(tag, vr, data, TransferSyntax.EXPLICIT_VR_BIG_ENDIAN);
}
示例11: 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;
}
示例12: ReadElementImplicitLittleEndian
/// <summary>
/// Reads and returns the next DICOM element starting at the current location in the DICOM binary reader
/// </summary>
/// <param name="dr">the binary reader which is reading the DICOM object</param>
/// <returns>the next DICOM element</returns>
public static IDICOMElement ReadElementImplicitLittleEndian(DICOMBinaryReader dr)
{
Tag tag = TagReader.ReadLittleEndian(dr);
VR vr = TagDictionary.GetVRFromTag(tag);
int length = LengthReader.ReadLittleEndian(VR.Null, dr);
byte[] data = DataReader.ReadLittleEndian(length, dr, TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN);
IDICOMElement el = ElementFactory.GenerateElement(tag, vr, data, TransferSyntax.IMPLICIT_VR_LITTLE_ENDIAN);
return el;
}
示例13: ReadObject
public static DICOMObject ReadObject(byte[] objectBytes, TransferSyntax syntax)
{
List<IDICOMElement> elements;
using (DICOMBinaryReader dr = new DICOMBinaryReader(objectBytes))
{
elements = DICOMElementReader.ReadAllElements(dr, syntax);
}
return new DICOMObject(elements);
}
示例14: ReadAllElementsImplicitLittleEndian
/// <summary>
/// Reads and returns all elements in implicit little endian format
/// </summary>
/// <param name="dr">the binary reader which is reading the DICOM object</param>
/// <returns>DICOM elements read</returns>
public static List<IDICOMElement> ReadAllElementsImplicitLittleEndian(DICOMBinaryReader dr)
{
List<IDICOMElement> elements = new List<IDICOMElement>();
while (dr.StreamPosition < dr.StreamLength)
{
elements.Add(ReadElementImplicitLittleEndian(dr));
}
return elements;
}
示例15: ReadAsyncOperations
public static AsyncOperations ReadAsyncOperations(DICOMBinaryReader dr)
{
AssertItemType(dr, "Async Operations", ItemType.ASYNCHRONOUS_OPERATIONS_WINDOW);
var ao = new AsyncOperations();
dr.Skip(2); // // PDU ID and Reserved Null Byte
int length = LengthReader.ReadBigEndian(dr, 2);
ao.MaxInvokeOperations = LengthReader.ReadBigEndian(dr, 2);
ao.MaxPerformOperations = LengthReader.ReadBigEndian(dr, 2);
return ao;
}