GZip Compression & Compact Framework

Here are some utils methods to compress/decompress byte data in gzip format.  Couldn’t really find many examples to inflate (decompress) the byte data after it’s been compressed…maybe i just didn’t Google hard enought ;-).  Pretty cool library…especaily when you reduce a bitmap 80-90%!!

Note: This is only a wrapper to the main SharpZipLib library available at http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx so you will need that library for the utils to work.

        /// <summary>
        /// Compress the raw data using gzip compression
        /// </summary>
        /// <param name=”rawData”></param>
        /// <returns></returns>
        public static byte[] DeflateData(byte[] data)
            MemoryStream stream = new MemoryStream();
            GZipOutputStream gzipOut = new GZipOutputStream(stream);
            return stream.ToArray();

        /// <summary>
        /// Decompress the data using gzip compression
        /// </summary>
        /// <param name=”data”></param>
        /// <returns></returns>
        public static byte[] InflateData(byte[] data)
            MemoryStream ms = new MemoryStream();
            Stream gzin = new GZipInputStream(ms);
            MemoryStream decompMemStream = new MemoryStream();
            int size = 2048;
            byte[] buffer = new byte[size];
                size = gzin.Read(buffer, 0, size);
                if (size > 0)
                    decompMemStream.Write(buffer, 0, size);

            return decompMemStream.ToArray();            

Perf Monitoring and Compact Framework

Scott Holden is working on a great tool that would be an awesome addition to the utils library when completed.  He is working on improving the mscoree.stat data that is provided for perf monitoring.  Looks like it will provide extra stats, remote monitoring and the ability to load the data to PerfMon and view it graphically.  Hopefully this could be completed sooner than later because I could sure use this now!!  If you need a beta tester let me know.

Thanks to Mike Zintel for the heads up on the up coming util.