Beispiel #1
0
        static void Main(string[] args)
        {
            // Create the compressor object
            LZOCompressor lzo = new LZOCompressor();

            // Build a quite redundant string
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < 10000; i++)
            {
                sb.Append("LZO.NET");
            }
            string str = sb.ToString();

            Console.WriteLine("Original-Length: " + str.Length);

            byte[] data = Encoding.Default.GetBytes(str);

            // Now compress the 70000 byte string to something much smaller
            byte[] compressed = lzo.Compress(data);
            Console.WriteLine("Compressed-Length: " + compressed.Length);

            // Decompress the string to its original content
            string str2 = Encoding.Default.GetString(lzo.Decompress(compressed));

            Console.WriteLine("Decompressed-Length: " + str2.Length);
            Console.WriteLine("Equality: " + str.Equals(str2));

            Console.WriteLine("benchmark...");
            Stopwatch stopWatch = new Stopwatch();
            int       count     = 0;

            stopWatch.Start();
            while (stopWatch.ElapsedMilliseconds < 2000)
            {
                lzo.Compress(data);
                count++;
            }
            stopWatch.Stop();
            Console.WriteLine("Compression throughput is (KByte/sec): " + data.Length * count / stopWatch.ElapsedMilliseconds);

            count = 0;
            stopWatch.Reset();
            stopWatch.Start();
            while (stopWatch.ElapsedMilliseconds < 2000)
            {
                lzo.Decompress(compressed);
                count++;
            }
            stopWatch.Stop();
            Console.WriteLine("Uncompression throughput is (KByte/sec): " + data.Length * count / stopWatch.ElapsedMilliseconds);

            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // Create the compressor object
            LZOCompressor lzo = new LZOCompressor();

            // Build a quite redundant string
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < 10000; i++)
            {
                sb.Append("LZO.NET");
            }
            string str = sb.ToString();
            Console.WriteLine("Original-Length: " + str.Length);

            byte[] data = Encoding.Default.GetBytes(str);

            // Now compress the 70000 byte string to something much smaller
            byte[] compressed = lzo.Compress(data);
            Console.WriteLine("Compressed-Length: " + compressed.Length);

            // Decompress the string to its original content
            string str2 = Encoding.Default.GetString(lzo.Decompress(compressed));
            Console.WriteLine("Decompressed-Length: " + str2.Length);
            Console.WriteLine("Equality: " + str.Equals(str2));

            Console.WriteLine("benchmark...");
            Stopwatch stopWatch = new Stopwatch();
            int count = 0;
            stopWatch.Start();
            while (stopWatch.ElapsedMilliseconds < 2000)
            {
                lzo.Compress(data);
                count++;
            }
            stopWatch.Stop();
            Console.WriteLine("Compression throughput is (KByte/sec): " + data.Length * count / stopWatch.ElapsedMilliseconds);

            count = 0;
            stopWatch.Reset();
            stopWatch.Start();
            while (stopWatch.ElapsedMilliseconds < 2000)
            {
                lzo.Decompress(compressed);
                count++;
            }
            stopWatch.Stop();
            Console.WriteLine("Uncompression throughput is (KByte/sec): " + data.Length * count / stopWatch.ElapsedMilliseconds);

            Console.ReadKey();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            LZOCompressor comp = new LZOCompressor();

            byte[] input         = File.ReadAllBytes(@"C:\Users\WHC\Desktop\rubbish\1.bin");
            int    decompressLen = 0x15D6;

            byte[] output = comp.DecompressRaw(input, decompressLen);
            Console.WriteLine(output.Length);
            string strResult = Encoding.GetEncoding(936).GetString(output);

            Console.WriteLine(strResult);
            Console.ReadKey();
        }
Beispiel #4
0
        /**解压线程*/
        private void deCompressFun()
        {
            while (isConnect)
            {
                try
                {
                    RecPacket     recPacket   = recPacketQueue.Dequeue();
                    LZOCompressor lzoCompress = new LZOCompressor();
                    if (recPacket != null)
                    {
                        RecPacket.PacketType      packetType    = recPacket.getPacketType();
                        DifferentBitmapWithCursor difbitWithCur = new DifferentBitmapWithCursor();
                        difbitWithCur.setPacketType(packetType);
                        switch (packetType)
                        {
                        case RecPacket.PacketType.BITMAP:
                            difbitWithCur.setBitmapType(recPacket.getBitmapType());
                            difbitWithCur.setCursorPoint(recPacket.getCursorPoint());
                            difbitWithCur.setDifPointsList(recPacket.getDifPointsList());
                            byte[] dataBytes = recPacket.getBitByts();
                            byte[] getByte   = lzoCompress.Decompress(dataBytes);
                            Bitmap temp      = (Bitmap)Bitmap.FromStream(new MemoryStream(getByte));

                            difbitWithCur.setDifBitmap(temp);
                            /**放入差异队列*/
                            deCompressDifQueue.Enqueue(difbitWithCur);
                            labelDif.Text = "差异队列大小:" + deCompressDifQueue.getQueueSize() + "\r\n";
                            break;

                        case RecPacket.PacketType.TEXT:
                            difbitWithCur.setStringValue(recPacket.getStringValue());
                            deCompressDifQueue.Enqueue(difbitWithCur);
                            labelDif.Text = "差异队列大小:" + deCompressDifQueue.getQueueSize() + "\r\n";
                            break;

                        default:
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Beispiel #5
0
 private static byte[] NativeLZODecompressor(byte[] input, int outputLength)
 {
     return(LZOCompressor.Decompress(input));
 }
Beispiel #6
0
 private static byte[] NativeLZO1X999Compressor(byte[] input, int length)
 {
     return(LZOCompressor.Compress(input, CompressionAlgorithm.LZO1X999));
 }
 public PackageDataDecompressor()
 {
     lzo = new LZOCompressor();
 }
Beispiel #8
0
 public static byte[] DecompressLZO(byte[] input)
 {
     return(LZOCompressor.Decompress(input));
 }