コード例 #1
0
ファイル: LzhamStream.cs プロジェクト: AndrewSav/Lzham.Net
 public LzhamStream(Stream stream, CompressionParameters mode, bool leaveOpen)
 {
     if (stream == null)
         throw new ArgumentNullException(nameof(stream));
     if (!stream.CanWrite)
         throw new ArgumentException("The base stream is not writeable", nameof(stream));
     _stream = stream;
     _leaveOpen = leaveOpen;
     _buffer = new byte[DefaultBufferSize];
     _compressionHandle = LzhamInterop.CompressInit(mode);
     if (_compressionHandle.IsInvalid)
     {
         throw new ApplicationException("Could not initialize compression stream with specified parameters");
     }
 }
コード例 #2
0
ファイル: LzhamInterop.cs プロジェクト: AndrewSav/Lzham.Net
 private static extern unsafe int lzham_compress2(CompressionHandle state, byte* inBuf, ref IntPtr inBufSize, byte* outBuf,
     ref IntPtr outBufSize, Flush flushType);
コード例 #3
0
ファイル: LzhamInterop.cs プロジェクト: AndrewSav/Lzham.Net
 private static extern unsafe int lzham_compress(CompressionHandle state, byte* inBuf, ref IntPtr inBufSize, byte* outBuf,
     ref IntPtr outBufSize, int noMoreInputBytesFlag);
コード例 #4
0
ファイル: LzhamInterop.cs プロジェクト: AndrewSav/Lzham.Net
 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 ArgumentException("Offset plus count is larger than the length of array", nameof(inBuf));
     }
     if (outBufOffset + outBufSize > outBuf.Length)
     {
         throw new ArgumentException("Offset plus count is larger than the length of array", nameof(outBuf));
     }
     fixed (byte* inBytes = inBuf)
     fixed (byte* 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;
     }
 }
コード例 #5
0
ファイル: LzhamInterop.cs プロジェクト: AndrewSav/Lzham.Net
 public static CompressionHandle CompressReinit(CompressionHandle state)
 {
     return lzham_compress_reinit(state);
 }
コード例 #6
0
ファイル: LzhamInterop.cs プロジェクト: AndrewSav/Lzham.Net
 private static extern CompressionHandle lzham_compress_reinit(CompressionHandle state);