当前位置: 首页>>代码示例>>C#>>正文


C# ZlibStream.Write方法代码示例

本文整理汇总了C#中Ionic.Zlib.ZlibStream.Write方法的典型用法代码示例。如果您正苦于以下问题:C# ZlibStream.Write方法的具体用法?C# ZlibStream.Write怎么用?C# ZlibStream.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ionic.Zlib.ZlibStream的用法示例。


在下文中一共展示了ZlibStream.Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Compress

        /// <summary>
        /// 지정된 데이타를 압축한다.
        /// </summary>
        /// <param name="input">압축할 Data</param>
        /// <returns>압축된 Data</returns>
        public override byte[] Compress(byte[] input) {
            if(IsDebugEnabled)
                log.Debug(CompressorTool.SR.CompressStartMsg);

            // check input data
            if(input.IsZeroLength()) {
                if(IsDebugEnabled)
                    log.Debug(CompressorTool.SR.InvalidInputDataMsg);

                return CompressorTool.EmptyBytes;
            }

            byte[] output;

            using(var outStream = new MemoryStream(input.Length)) {
                using(var zlib = new ZlibStream(outStream, CompressionMode.Compress)) {
                    zlib.Write(input, 0, input.Length);
                }
                output = outStream.ToArray();
            }

            if(IsDebugEnabled)
                log.Debug(CompressorTool.SR.CompressResultMsg, input.Length, output.Length, output.Length / (double)input.Length);

            return output;
        }
开发者ID:debop,项目名称:NFramework,代码行数:31,代码来源:IonicZlibCompressor.cs

示例2: Compress

 public static byte[] Compress(byte[] input)
 {
     using (MemoryStream ms = new MemoryStream()) {
         using (ZlibStream zls = new ZlibStream(ms, CompressionMode.Compress, CompressionLevel.BestSpeed)) {
             zls.Write(input, 0, input.Length);
         }
         return ms.ToArray();
     }
 }
开发者ID:The6P4C,项目名称:Kalkimg,代码行数:9,代码来源:Utility.cs

示例3: Compress

 /// <summary>
 /// Compress to CompressedData
 /// </summary>
 public static MemoryStream Compress(byte[] buffer)
 {
     var output = new MemoryStream();
     using (ZlibStream zout = new ZlibStream(output, CompressionMode.Compress))
     {
         zout.Write(buffer, 0, buffer.Length);
         zout.Flush();
     }
     return output;
 }
开发者ID:mctraveler,项目名称:MineSharp,代码行数:13,代码来源:Compression.cs

示例4: Compress

 internal static byte[] Compress(byte[] buffer)
 {
     using (var output = new MemoryStream())
     {
         using (Stream compressor = new ZlibStream(output, CompressionMode.Compress, CompressionLevel.BestCompression))
         {
             compressor.Write(buffer, 0, buffer.Length);
         }
         return output.ToArray();
     }
 }
开发者ID:engrin,项目名称:GzsTool,代码行数:11,代码来源:Compression.cs

示例5: ZibCompress

 public static byte[] ZibCompress(byte[] input)
 {
     using (var ms = new System.IO.MemoryStream())
     {
         using (var zs = new ZlibStream(ms, CompressionMode.Compress, CompressionLevel.BestCompression, true))
         {
             zs.Write(input, 0, input.Length);
         }
         return ms.ToArray();
     }
 }
开发者ID:RobertHu,项目名称:TraderServer,代码行数:11,代码来源:ZlibHelper.cs

示例6: ZibCompress

 public static UnmanagedMemory ZibCompress(byte[] input)
 {
     using (var ms = new TraderMemoryStream(500 * 1024))
     {
         using (var zs = new ZlibStream(ms, CompressionMode.Compress, CompressionLevel.BestCompression, true))
         {
             zs.Write(input, 0, input.Length);
         }
         return ms.Buffer;
     }
 }
开发者ID:RobertHu,项目名称:-NewTraderServer,代码行数:11,代码来源:ZlibHelper.cs

示例7: CompressZlib

        public static byte[] CompressZlib(byte[] bytes)
        {
            using (var ms = new MemoryStream())
            {
                using (var zip = new ZlibStream(ms, CompressionMode.Compress, true))
                {
                    zip.Write(bytes, 0, bytes.Length);
                }

                return ms.ToArray();
            }
        }
开发者ID:venusdharan,项目名称:Titanium-Web-Proxy,代码行数:12,代码来源:Compression.cs

示例8: ZlibDecompress

        static byte[] ZlibDecompress(byte[] input, int length)
        {
            using (var ms = new System.IO.MemoryStream())
            {
                using (var compressor = new Ionic.Zlib.ZlibStream(ms, CompressionMode.Decompress, CompressionLevel.BestCompression))
                {
                    compressor.Write(input, 0, length);
                }

                return ms.ToArray();
            }
        }
开发者ID:Ramzawulf,项目名称:unityassets,代码行数:12,代码来源:VoiceChatUtils.cs

示例9: Decomp

        public static void Decomp(byte[] input, Stream outputStream)
        {
            using (var zipStream = new ZlibStream(outputStream, CompressionMode.Decompress))
            {
                using (var inputStream = new MemoryStream(input))
                {
                    byte[] buffer = input.Length > 4096 ? new byte[4096] : new byte[input.Length];

                    int size;

                    while ((size = inputStream.Read(buffer, 0, buffer.Length)) != 0)
                        zipStream.Write(buffer, 0, size);
                }
            }
        }
开发者ID:Scrivener07,项目名称:moddingSuite,代码行数:15,代码来源:Compressing.cs

示例10: Compress

        public static byte[] Compress(this byte[] uncompressed, int level)
        {
            if (level == 0)
                return uncompressed;

            byte[] result;
            using (var ms = new MemoryStream())
            {
                using (var compressor =
                        new ZlibStream(ms, CompressionMode.Compress, CompressionLevel.Level0+level))
                    compressor.Write(uncompressed, 0, uncompressed.Length);
                result =  ms.ToArray();
            }

            // If compression did not improve the situation, then use
            // uncompressed bytes.
            if (result.Length >= uncompressed.Length)
                return uncompressed;

            return result;
        }
开发者ID:lgatto,项目名称:proteowizard,代码行数:21,代码来源:UtilDB.cs

示例11: SubmitBulkOperationsAsync

        public void SubmitBulkOperationsAsync(string callingUrl, Guid sessionId, OPS operations, object userState)
        {
            MemoryStream operationsXml = null;
            MemoryStream compressedOperationsStream = null;
            ZlibStream zipStream = null;

            try
            {
                operationsXml = new MemoryStream();

                DataContractSerializer serializer = new DataContractSerializer(typeof(OPS));

                serializer.WriteObject(operationsXml, operations);

                byte[] operationsXmlBytes = operationsXml.ToArray();
                compressedOperationsStream = new MemoryStream();

                using (zipStream = new ZlibStream(compressedOperationsStream, CompressionMode.Compress))
                {
                    zipStream.Write(operationsXmlBytes, 0, operationsXmlBytes.Length);
                }

                byte[] compressedOperationsXmlBytes = compressedOperationsStream.ToArray();

                string compressedOperations = Convert.ToBase64String(compressedOperationsXmlBytes);

                BOCAsync(callingUrl, sessionId, compressedOperations, userState);
            }
            finally
            {
                if (operationsXml != null)
                {
                    operationsXml.Dispose();
                    operationsXml = null;
                }
            }
        }
开发者ID:chris-tomich,项目名称:Glyma,代码行数:37,代码来源:TransactionalMappingToolServiceClient.cs

示例12: ZCompressOSD

        public static OSD ZCompressOSD(OSD inOsd, bool useHeader)
        {
            OSD osd = null;

            byte[] data = OSDParser.SerializeLLSDBinary(inOsd, useHeader);

            using (MemoryStream msSinkCompressed = new MemoryStream())
            {
                using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkCompressed, 
                    Ionic.Zlib.CompressionMode.Compress, CompressionLevel.BestCompression, true))
                {
                    zOut.Write(data, 0, data.Length);
                }

                msSinkCompressed.Seek(0L, SeekOrigin.Begin);
                osd = OSD.FromBinary(msSinkCompressed.ToArray());
            }

            return osd;
        }
开发者ID:ffoliveira,项目名称:opensimulator,代码行数:20,代码来源:MaterialsModule.cs

示例13: AddSlot

 public void AddSlot(slot cv_slot)
 {
     AddShort(cv_slot.s_short);
     if(slot.IsGziped(cv_slot.s_short))
     {
         ZlibStream Compress = new ZlibStream(stream, CompressionMode.Compress);
         Compress.Write(cv_slot.GZipData, 0, cv_slot.GZipData.Length);
     }
 }
开发者ID:ultimakaz,项目名称:lib-open-craft,代码行数:9,代码来源:PacketHandler.cs

示例14: Compress

        /// <summary>
        /// Compresses the specified data.
        /// </summary>
        /// <param name="data">The data.</param>
        /// <param name="compressionLevel">The compression level.</param>
        /// <returns></returns>
        private static byte[] Compress(byte[] data, CompressionLevel compressionLevel = CompressionLevel.Default)
        {
            // While the CgBI PNG image data is compressed with Deflate, a "real" PNG must use Zlib.
            using (var output = new MemoryStream())
            {
                using (var deflateStream = new ZlibStream(output, CompressionMode.Compress, compressionLevel, true))
                {
                    deflateStream.Write(data, 0, data.Length);
                }

                return output.ToArray();
            }
        }
开发者ID:osuritz,项目名称:PNGNormalizer,代码行数:19,代码来源:PngFile.cs

示例15: writeToStreamOld

        private void writeToStreamOld(Stream s, bool le, bool readOnly)
        {
            bool compress = true;
            bool base64 = true;

            using (var tw = new StreamWriter(s, System.Text.Encoding.ASCII))
            {
                tw.NewLine = "\n";
                tw.WriteLine("Type: Floppy");

                if (readOnly)
                    tw.WriteLine("Access: Read-Only");
                else
                    tw.WriteLine("Access: Read-Write");

                if (le)
                    tw.WriteLine("Byte-Order: Little-Endian");
                else
                    tw.WriteLine("Byte-Order: Big-Endian");

                int lb = 0, hb = 1;
                if (!le)
                {
                    lb = 1;
                    hb = 0;
                }

                byte[] bytes, cbytes;

                bytes = new byte[1440 * 1024];
                for (int i = 0; i < _words.Length; ++i)
                {
                    var j = 2 * i;
                    bytes[j + lb] = (byte)_words[i];
                    bytes[j + hb] = (byte)(_words[i] >> 8);
                }

                if (compress)
                {
                    tw.WriteLine("Compression: Zlib");
                    using (var ms = new MemoryStream())
                    {
                        using (var cmpr = new ZlibStream(ms, CompressionMode.Compress, CompressionLevel.BestCompression, leaveOpen: true))
                        {
                            cmpr.Write(bytes, 0, bytes.Length);
                            cmpr.Flush();
                        }
                        cbytes = ms.ToArray();
                    }
                }
                else
                {
                    tw.WriteLine("Compression: None");
                    cbytes = bytes;
                }

                if (base64)
                {
                    var encoded = Convert.ToBase64String(cbytes, Base64FormattingOptions.InsertLineBreaks);

                    tw.WriteLine("Encoding: Base64");
                    tw.WriteLine("Content-Length: {0}", encoded.Length);
                    tw.WriteLine();
                    tw.WriteLine(encoded);
                }
                else
                {
                    tw.WriteLine("Encoding: None");
                    tw.WriteLine("Content-Length: {0}", cbytes.Length);
                    tw.WriteLine();
                    tw.Flush();
                    tw.BaseStream.Write(bytes, 0, cbytes.Length);
                }
            }
        }
开发者ID:DanielKeep,项目名称:0x10c,代码行数:75,代码来源:Disk.cs


注:本文中的Ionic.Zlib.ZlibStream.Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。