public void ZLib()
        {
            Joveler.Compression.ZLib.ZLibCompressOptions compOpts = new Joveler.Compression.ZLib.ZLibCompressOptions()
            {
                BufferSize = BufferSize,
            };

            Joveler.Compression.ZLib.ZLibDecompressOptions decompOpts = new Joveler.Compression.ZLib.ZLibDecompressOptions()
            {
                BufferSize = BufferSize,
            };

            byte[] zlibData;
            using (MemoryStream ms = new MemoryStream())
            {
                using (MemoryStream rms = new MemoryStream(_srcData))
                    using (Joveler.Compression.ZLib.ZLibStream xzs = new Joveler.Compression.ZLib.ZLibStream(ms, compOpts))
                    {
                        rms.CopyTo(xzs);
                    }
                zlibData = ms.ToArray();
            }

            using (MemoryStream ms = new MemoryStream())
            {
                using (MemoryStream rms = new MemoryStream(zlibData))
                    using (Joveler.Compression.ZLib.ZLibStream xzs = new Joveler.Compression.ZLib.ZLibStream(rms, decompOpts))
                    {
                        xzs.CopyTo(ms);
                    }
            }
        }
Esempio n. 2
0
        public double ZLib_Native()
        {
            long compLen;

            byte[] rawData = SrcFiles[SrcFileName];
            using (MemoryStream ms = new MemoryStream())
            {
                Joveler.Compression.ZLib.ZLibCompressOptions compOpts = new Joveler.Compression.ZLib.ZLibCompressOptions()
                {
                    Level     = NativeZLibLevelDict[Level],
                    LeaveOpen = true,
                };

                using (MemoryStream rms = new MemoryStream(rawData))
                    using (Joveler.Compression.ZLib.ZLibStream zs = new Joveler.Compression.ZLib.ZLibStream(ms, compOpts))
                    {
                        rms.CopyTo(zs);
                    }

                ms.Flush();
                compLen = ms.Position;
            }

            CompRatio = (double)compLen / rawData.Length;
            return(CompRatio);
        }