public ZopfliStream(Stream inner, ZopfliFormat type, ZopfliOptions options, bool leaveOpen) { _innerStream = inner; this.type = type; this.options = options; this.leaveOpen = leaveOpen; }
/// <summary> /// Internal convert method to convert byte array to compressed byte array /// </summary> /// <param name="data_in">Uncompressed data array</param> /// <param name="type">Format type, DEFLATE, GZIP, ZLIB</param> /// <param name="options">Compression options</param> /// <returns>Compressed data array</returns> public static byte[] compress(byte[] data_in, ZopfliFormat type, ZopfliOptions options) { IntPtr result = IntPtr.Zero; UIntPtr result_size = UIntPtr.Zero; try { // Get image data length UIntPtr data_size = (UIntPtr)data_in.Length; // Compress the data via native methods if (Environment.Is64BitProcess) { ZopfliCompressor64.ZopfliCompress(ref options, type, data_in, data_in.Length, ref result, ref result_size); } else { ZopfliCompressor32.ZopfliCompress(ref options, type, data_in, data_in.Length, ref result, ref result_size); } // Copy data back to managed memory and return return(NativeUtilities.GetDataFromUnmanagedMemory(result, (int)result_size)); } catch { throw; } finally { // Free unmanaged memory Marshal.FreeHGlobal(result); } }
public ZopfliStream(Stream inner, ZopfliFormat type, bool leaveOpen) { _innerStream = inner; this.type = type; options = new ZopfliOptions(); this.leaveOpen = leaveOpen; }
public ZopfliStream(Stream inner, ZopfliFormat type, ZopfliOptions options) { _innerStream = inner; this.type = type; this.options = options; this.leaveOpen = false; }
public ZopfliStream(Stream inner, ZopfliFormat type) { _innerStream = inner; this.type = type; options = new ZopfliOptions(); this.leaveOpen = false; }
public ZopfliStream(Stream inner) { _innerStream = inner; type = ZopfliFormat.ZOPFLI_FORMAT_DEFLATE; options = new ZopfliOptions(); this.leaveOpen = false; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (!leaveOpen) { _innerStream.Dispose(); } options = null; }
protected override void Dispose(bool disposing) { base.Dispose(disposing); _innerStream.Dispose(); options = null; }
public ZopfliStream(Stream inner) { _innerStream = inner; type = ZopfliFormat.ZOPFLI_FORMAT_DEFLATE; options = new ZopfliOptions(); }