Ejemplo n.º 1
0
        public static int WriteGroupLittleEndian(DICOMBinaryWriter dw, DICOMWriteSettings settings, DICOMObject d, IDICOMElement el)
        {
            byte[]       groupBytes = WriteGroupBytesLittleEndian(d, settings, el.Tag.Group);
            int          length     = groupBytes.Length;
            UnsignedLong ul         = el as UnsignedLong;

            ul.SetData((uint)length);
            DICOMElementWriter.WriteLittleEndian(dw, settings, ul);
            dw.Write(groupBytes);
            return(d.Elements.Where(elm => elm.Tag.Group == ul.Tag.Group).ToList().Count - 1);
        }
Ejemplo n.º 2
0
 public static void WriteObjectLittleEndian(DICOMBinaryWriter dw, DICOMWriteSettings settings, DICOMObject d)
 {
     for (int i = 0; i < d.Elements.Count; i++)
     {
         IDICOMElement      el = d.Elements[i];
         DICOMWriteSettings currentSettings = IsFileMetaGroup(el) ? settings.GetFileMetaSettings() : settings;
         if (GroupWriter.IsGroupHeader(el))
         {
             int skip = GroupWriter.WriteGroupLittleEndian(dw, currentSettings, d, el);
             i += skip;
         }
         else
         {
             DICOMElementWriter.WriteLittleEndian(dw, currentSettings, el);
         }
     }
 }
Ejemplo n.º 3
0
        private static byte[] WriteGroupBytesLittleEndian(DICOMObject d, DICOMWriteSettings settings, string groupID)
        {
            List <IDICOMElement> groupElements = d.Elements.Where(el => el.Tag.Group == groupID).ToList();

            byte[] groupBytes;
            using (MemoryStream stream = new MemoryStream())
            {
                using (DICOMBinaryWriter groupDW = new DICOMBinaryWriter(stream))
                {
                    foreach (IDICOMElement el in groupElements)
                    {
                        if (!IsGroupHeader(el))
                        {
                            DICOMElementWriter.WriteLittleEndian(groupDW, settings, el);
                        }
                    }
                }
                groupBytes = stream.ToArray();
            }
            return(groupBytes);
        }