private ZlibHeader( byte compressionMethod, byte compressionInfo, byte check, bool dict, FLevel level) { CompressionMethod = compressionMethod; CompressionInfo = compressionInfo; Check = check; Dict = dict; Level = level; }
public static ZlibHeader Decode(byte cmf, byte flg) { byte CompressionMethod = Convert.ToByte(cmf & 0x0F); byte CompressionInfo = Convert.ToByte((cmf & 0xF0) >> 4); byte FCheck = Convert.ToByte(flg & 0x1F); bool FDict = Convert.ToBoolean(Convert.ToByte((flg & 0x20) >> 5)); FLevel Level = (FLevel)Convert.ToByte((flg & 0xC0) >> 6); return(new ZlibHeader(CompressionMethod, CompressionInfo, FCheck, FDict, Level)); }
public static CompressionLevel ConvertLevel(FLevel level) { switch (level) { case FLevel.Faster: return(CompressionLevel.NoCompression); case FLevel.Default: return(CompressionLevel.Fastest); case FLevel.Optimal: return(CompressionLevel.Optimal); default: throw new ArgumentOutOfRangeException(nameof(level)); } }
public ZlibHeader(byte compressionMethod, byte compressionInfo, bool dict, FLevel level) : this() { if (compressionMethod > 15) { throw new ArgumentOutOfRangeException( nameof(compressionMethod), "Argument cannot be greater than 15."); } if (compressionInfo > 15) { throw new ArgumentOutOfRangeException( nameof(compressionInfo), "Argument cannot be greater than 15."); } CompressionMethod = compressionMethod; CompressionInfo = compressionInfo; Dict = dict; Level = level; byte byteFLG = (byte)((byte)Level << 1); byteFLG |= Convert.ToByte(Dict); Check = Convert.ToByte(31 - Convert.ToByte((GetCMF() * 256 + byteFLG) % 31)); }