Ejemplo n.º 1
0
 public virtual void Compress()
 {
     if (Compressable && (_unCompressedStream != null))
     {
         var stream = _unCompressedStream;
         stream.Position = 0;
         if (StreamWrapper != null)
         {
             StreamWrapper.Stream = CompressionWorker.Compress(stream, Compression);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Changes the transfer syntax used by the DICOMData structure (compressed/uncompressed, endianness, implicit/explicit VR, etc.) to a new syntax.
        /// </summary>
        /// <param name="newSyntax">The new transfer syntax to change to.</param>
        /// <returns>Returns <c>true</c> if the change was successful, or <c>false</c> if an error was encountered.</returns>
        public bool ChangeTransferSyntax(TransferSyntax newSyntax)
        {
            if (!CanChangeTransferSyntax(newSyntax))
            {
                return(false);
            }

            CompressionInfo oldCompression = TransferSyntax.Compression;
            CompressionInfo newCompression = newSyntax.Compression;

            if (oldCompression != newCompression)
            {
                //Is it compressed?
                if (oldCompression != CompressionInfo.None)
                {
                    //Attempt to uncompress
                    if (!this.Uncompress())
                    {
                        return(false);
                    }
                }

                //Need to compress it?
                if (newCompression != CompressionInfo.None)
                {
                    //Attempt to compress
                    if (!CompressionWorker.Compress(this, newSyntax))
                    {
                        return(false);
                    }
                }
            }

            //Compressionworker will do this...
            //TransferSyntax = newSyntax;
            return(true);
        }