public override byte[] Decode(Bytes.Buffer data, PdfDirectObject parameters, IDictionary <PdfName, PdfDirectObject> header) { // get decode parameters PdfDictionary decodeParms = parameters as PdfDictionary; var ccittFaxParams = new CCITTFaxParams( K: decodeParms.GetInt(PdfName.K), endOfLine: decodeParms.GetBool(PdfName.EndOfLine), encodedByteAlign: decodeParms.GetBool(PdfName.EncodedByteAlign), columns: decodeParms.GetInt(PdfName.Columns), rows: decodeParms.GetInt(PdfName.Rows), endOfBlock: decodeParms.GetBool(PdfName.EndOfBlock), blackIs1: decodeParms.GetBool(PdfName.BlackIs1) ); var decoder = new CCITTFaxDecoder(data, ccittFaxParams); using (var output = new Bytes.Buffer()) { var currentByte = 0; while ((currentByte = decoder.ReadNextChar()) > -1) { output.Append(FiltersExtension.ToByte(currentByte)); } return(output.GetBuffer()); } }
//BEWARE: codeTable must be local to each method, because there is only // one instance of each filter public override byte[] Decode(Bytes.Buffer data, PdfDirectObject parameters, IDictionary <PdfName, PdfDirectObject> header) { PdfDictionary decodeParams = (PdfDictionary)parameters; int earlyChange = decodeParams?.GetInt(PdfName.EarlyChange, 1) ?? 1; if (earlyChange != 0 && earlyChange != 1) { earlyChange = 1; } var result = DoLZWDecode(data, earlyChange); return(DecodePredictor(result, parameters, header)); }