Пример #1
0
        public int DecompressSingle(byte[] input, int inputLength, ref byte[] output, int outputLength)
        {
            uint outSize = (uint)outputLength;

            uint result = LzxNativeMethods.LDIDecompress(context, input, (uint)inputLength, output, out outSize);

            return((int)outSize);
        }
Пример #2
0
        public int CompressSingle(byte[] input, int inputLength, ref byte[] output, int outputLength)
        {
            uint dstResultLength = 0;

            uint result = LzxNativeMethods.LCICompress(context, input, (uint)inputLength, null, (uint)outputLength, out dstResultLength);

            result = LzxNativeMethods.LCIFlushCompressorOutput(context);

            int compressedLength = dst.Length;

            Buffer.BlockCopy(dst, 0, output, 0, compressedLength);
            dst = null;

            return(compressedLength);
        }
Пример #3
0
        public LzxDecompression()
        {
            uint dataBlockMax = 0x8000;

            var config = new LzxNativeMethods.LZX_CONFIGURATION();

            config.CompressionWindowSize = 0x20000;
            config.SecondPartitionSize   = 1;

            uint decompressBufferMin = 0;

            context = IntPtr.Zero;

            uint result = LzxNativeMethods.LDICreateDecompression(out dataBlockMax, &config, LzxNativeMethods.managed_mem_alloc, LzxNativeMethods.managed_mem_free, IntPtr.Zero, out decompressBufferMin, out context);
        }
Пример #4
0
        public LzxCompression()
        {
            uint dataBlockMax = 0x8000;

            var config = new LzxNativeMethods.LZX_CONFIGURATION();

            config.CompressionWindowSize = 0x20000;
            config.SecondPartitionSize   = 1;

            context = IntPtr.Zero;

            uint pcbDstBufferMin = 0;

            uint result = LzxNativeMethods.LCICreateCompression(out dataBlockMax, &config, LzxNativeMethods.managed_mem_alloc, LzxNativeMethods.managed_mem_free, out pcbDstBufferMin, out context, delegate(IntPtr fci_data, byte *pbCompressed, uint cbCompressed, uint cbUncompressed) {
                dst = new byte[cbCompressed];

                for (var i = 0; i < cbCompressed; i++)
                {
                    dst[i] = *pbCompressed;
                    pbCompressed++;
                }
            }, IntPtr.Zero);
        }