Esempio n. 1
0
        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());
            }
        }