Exemplo n.º 1
0
        /// <summary>
        /// Creates a clone of this DICOM object
        /// </summary>
        /// <returns>a new copied DICOM object</returns>
        public DICOMObject Clone()
        {
            List <IDICOMElement> copy = new List <IDICOMElement>();

            foreach (var el in Elements)
            {
                using (var ms = new MemoryStream())
                {
                    using (var dw = new DICOMBinaryWriter(ms))
                    {
                        DICOMElementWriter.Write(dw, DICOMIOSettings.Default(), el);
                    }
                    using (var dr = new DICOMBinaryReader(ms.ToArray()))
                    {
                        copy.Add(DICOMElementReader.ReadElementImplicitLittleEndian(dr));
                    }
                }
            }

            return(new DICOMObject(copy));
        }
Exemplo n.º 2
0
        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 = DICOMIOSettings.Default();

            using (var ms = new MemoryStream())
            {
                using (var dw = new DICOMBinaryWriter(ms))
                {
                    DICOMElementWriter.Write(dw, DICOMIOSettings.Default(), ds);
                }
                written = ms.ToArray();
            }

            using (var dr = new DICOMBinaryReader(written))
            {
                var read = DICOMElementReader.ReadElementImplicitLittleEndian(dr) as DecimalString;
                CollectionAssert.AreEqual(ds.DData_, read.Data_);
            }
        }