本文整理汇总了C#中DicomAttributeCollection.CalculateGroupWriteLength方法的典型用法代码示例。如果您正苦于以下问题:C# DicomAttributeCollection.CalculateGroupWriteLength方法的具体用法?C# DicomAttributeCollection.CalculateGroupWriteLength怎么用?C# DicomAttributeCollection.CalculateGroupWriteLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DicomAttributeCollection
的用法示例。
在下文中一共展示了DicomAttributeCollection.CalculateGroupWriteLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Write
public DicomWriteStatus Write(TransferSyntax syntax, DicomAttributeCollection dataset, DicomWriteOptions options)
{
TransferSyntax = syntax;
foreach (DicomAttribute item in dataset)
{
if (item.IsEmpty)
continue;
if (item.Tag.Element == 0x0000)
continue;
if (Flags.IsSet(options, DicomWriteOptions.CalculateGroupLengths)
&& item.Tag.Group != _group)
{
_group = item.Tag.Group;
_writer.Write((ushort) _group);
_writer.Write((ushort) 0x0000);
if (_syntax.ExplicitVr)
{
_writer.Write((byte) 'U');
_writer.Write((byte) 'L');
_writer.Write((ushort) 4);
}
else
{
_writer.Write((uint) 4);
}
_writer.Write((uint) dataset.CalculateGroupWriteLength(_group, _syntax, options));
}
_writer.Write((ushort) item.Tag.Group);
_writer.Write((ushort) item.Tag.Element);
if (_syntax.ExplicitVr)
{
_writer.Write((byte) item.Tag.VR.Name[0]);
_writer.Write((byte) item.Tag.VR.Name[1]);
}
if (item is DicomAttributeSQ)
{
var sq = item as DicomAttributeSQ;
if (_syntax.ExplicitVr)
_writer.Write((ushort) 0x0000);
if (Flags.IsSet(options, DicomWriteOptions.DigitalSignatureMacEncoding))
{
// length field is not written when generating digital signature MAC
}
else if (Flags.IsSet(options, DicomWriteOptions.ExplicitLengthSequence))
{
int hl = _syntax.ExplicitVr ? 12 : 8;
_writer.Write((uint) sq.CalculateWriteLength(_syntax, options & ~DicomWriteOptions.CalculateGroupLengths) - (uint) hl);
}
else
{
_writer.Write((uint) _undefinedLength);
}
foreach (DicomSequenceItem ids in (DicomSequenceItem[]) sq.Values)
{
_writer.Write((ushort) DicomTag.Item.Group);
_writer.Write((ushort) DicomTag.Item.Element);
if (Flags.IsSet(options, DicomWriteOptions.DigitalSignatureMacEncoding))
{
// length field is not written when generating digital signature MAC
}
else if (Flags.IsSet(options, DicomWriteOptions.ExplicitLengthSequenceItem))
{
_writer.Write((uint) ids.CalculateWriteLength(_syntax, options & ~DicomWriteOptions.CalculateGroupLengths));
}
else
{
_writer.Write((uint) _undefinedLength);
}
Write(TransferSyntax, ids, options & ~DicomWriteOptions.CalculateGroupLengths);
if (!Flags.IsSet(options, DicomWriteOptions.ExplicitLengthSequenceItem)
&& !Flags.IsSet(options, DicomWriteOptions.DigitalSignatureMacEncoding))
{
_writer.Write((ushort) DicomTag.ItemDelimitationItem.Group);
_writer.Write((ushort) DicomTag.ItemDelimitationItem.Element);
_writer.Write((uint) 0x00000000);
}
}
if (Flags.IsSet(options, DicomWriteOptions.DigitalSignatureMacEncoding))
{
_writer.Write((ushort) DicomTag.SequenceDelimitationItem.Group);
_writer.Write((ushort) DicomTag.SequenceDelimitationItem.Element);
}
else if (!Flags.IsSet(options, DicomWriteOptions.ExplicitLengthSequence))
{
_writer.Write((ushort) DicomTag.SequenceDelimitationItem.Group);
_writer.Write((ushort) DicomTag.SequenceDelimitationItem.Element);
_writer.Write((uint) 0x00000000);
//.........这里部分代码省略.........
示例2: Write
public DicomWriteStatus Write(TransferSyntax syntax, DicomAttributeCollection dataset, DicomWriteOptions options)
{
TransferSyntax = syntax;
foreach (DicomAttribute item in dataset)
{
if (item.Tag.Element == 0x0000)
continue;
if (item.IsEmpty)
continue;
if (Flags.IsSet(options, DicomWriteOptions.CalculateGroupLengths)
&& item.Tag.Group != _group && item.Tag.Group <= 0x7fe0)
{
_group = item.Tag.Group;
_writer.Write((ushort)_group);
_writer.Write((ushort)0x0000);
if (_syntax.ExplicitVr)
{
_writer.Write((byte)'U');
_writer.Write((byte)'L');
_writer.Write((ushort)4);
}
else
{
_writer.Write((uint)4);
}
_writer.Write((uint)dataset.CalculateGroupWriteLength(_group, _syntax, options));
}
_writer.Write((ushort)item.Tag.Group);
_writer.Write((ushort)item.Tag.Element);
if (_syntax.ExplicitVr)
{
_writer.Write((byte)item.Tag.VR.Name[0]);
_writer.Write((byte)item.Tag.VR.Name[1]);
}
if (item is DicomAttributeSQ)
{
DicomAttributeSQ sq = item as DicomAttributeSQ;
if (_syntax.ExplicitVr)
_writer.Write((ushort)0x0000);
if (Flags.IsSet(options, DicomWriteOptions.ExplicitLengthSequence))
{
int hl = _syntax.ExplicitVr ? 12 : 8;
_writer.Write((uint)sq.CalculateWriteLength(_syntax, options & ~DicomWriteOptions.CalculateGroupLengths) - (uint)hl);
}
else
{
_writer.Write((uint)UndefinedLength);
}
foreach (DicomSequenceItem ids in item.Values as DicomSequenceItem[])
{
_writer.Write((ushort)DicomTag.Item.Group);
_writer.Write((ushort)DicomTag.Item.Element);
if (Flags.IsSet(options, DicomWriteOptions.ExplicitLengthSequenceItem))
{
_writer.Write((uint)ids.CalculateWriteLength(_syntax, options & ~DicomWriteOptions.CalculateGroupLengths));
}
else
{
_writer.Write((uint)UndefinedLength);
}
Write(this.TransferSyntax, ids, options & ~DicomWriteOptions.CalculateGroupLengths);
if (!Flags.IsSet(options, DicomWriteOptions.ExplicitLengthSequenceItem))
{
_writer.Write((ushort)DicomTag.ItemDelimitationItem.Group);
_writer.Write((ushort)DicomTag.ItemDelimitationItem.Element);
_writer.Write((uint)0x00000000);
}
}
if (!Flags.IsSet(options, DicomWriteOptions.ExplicitLengthSequence))
{
_writer.Write((ushort)DicomTag.SequenceDelimitationItem.Group);
_writer.Write((ushort)DicomTag.SequenceDelimitationItem.Element);
_writer.Write((uint)0x00000000);
}
}
else if (item is DicomFragmentSequence)
{
DicomFragmentSequence fs = item as DicomFragmentSequence;
if (_syntax.ExplicitVr)
_writer.Write((ushort)0x0000);
_writer.Write((uint)UndefinedLength);
_writer.Write((ushort)DicomTag.Item.Group);
_writer.Write((ushort)DicomTag.Item.Element);
//.........这里部分代码省略.........