Пример #1
0
        public static unsafe CompressStatus Compress2(CompressionHandle state, byte[] inBuf, ref int inBufSize, int inBufOffset, byte[] outBuf, ref int outBufSize, int outBufOffset, Flush flushType)
        {
            if (inBufOffset + inBufSize > inBuf.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(inBuf), "Offset + Size is larger than the length of the array.");
            }
            if (outBufOffset + outBufSize > outBuf.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(outBuf), "Offset + Size is larger than the length of the array.");

                fixed(byte *inBytes = inBuf, outBytes = outBuf)
                {
                    IntPtr         inSize  = new IntPtr(inBufSize);
                    IntPtr         outSize = new IntPtr(outBufSize);
                    CompressStatus result  = (CompressStatus)lzham_compress2(state, inBytes + inBufOffset, ref inSize, outBytes + outBufOffset, ref outSize, flushType);

                    inBufSize  = inSize.ToInt32();
                    outBufSize = outSize.ToInt32();
                    return(result);
                }
        }
Пример #2
0
 public static CompressionHandle CompressReinit(CompressionHandle state)
 {
     return(lzham_compress_reinit(state));
 }