Example #1
0
 /// <summary>
 /// Creates a <see cref="ByteBuffer"/> filled with the values from this <see cref="DicomElementBinaryData{T}"/>.
 /// </summary>
 /// <param name="endian">The endianess of the <see cref="ByteBuffer"/>.</param>
 /// <returns>A new <see cref="ByteBuffer"/> instance containing the values of this instance.</returns>
 internal ByteBuffer CreateByteBuffer(Endian endian)
 {
     if (_array != null)
     {
         var length  = _array.Length * _sizeOfT;
         var byteVal = new byte[length];
         Buffer.BlockCopy(_array, 0, byteVal, 0, length);
         return(new ByteBuffer(byteVal, endian));
     }
     else
     {
         var bb = new ByteBuffer(endian, _stream.Length);
         _stream.WriteTo(bb.Stream);
         return(bb);
     }
 }
Example #2
0
        public static void WriteXmlAndGzip(StudyXmlMemento theMemento, Stream theXmlStream, Stream theGzipStream)
        {
            // Write to a memory stream, then flush to disk and to gzip file
            var ms = new LargeMemoryStream();

            Write(theMemento, ms);

            var compressedzipStream = new GZipStream(theGzipStream, CompressionMode.Compress, true);

            ms.Seek(0, SeekOrigin.Begin);
            ms.WriteTo(compressedzipStream);

            // Close the stream.
            compressedzipStream.Flush();
            compressedzipStream.Close();

            ms.Seek(0, SeekOrigin.Begin);
            ms.WriteTo(theXmlStream);

            // Force a flush.
            theXmlStream.Flush();
            theGzipStream.Flush();
        }