UNPKG

2.06 kBJavaScriptView Raw
1/**
2 * @licstart The following is the entire license notice for the
3 * JavaScript code in this page
4 *
5 * Copyright 2022 Mozilla Foundation
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * @licend The above is the entire license notice for the
20 * JavaScript code in this page
21 */
22"use strict";
23
24Object.defineProperty(exports, "__esModule", {
25 value: true
26});
27exports.CCITTFaxStream = void 0;
28
29var _ccitt = require("./ccitt.js");
30
31var _decode_stream = require("./decode_stream.js");
32
33var _primitives = require("./primitives.js");
34
35class CCITTFaxStream extends _decode_stream.DecodeStream {
36 constructor(str, maybeLength, params) {
37 super(maybeLength);
38 this.str = str;
39 this.dict = str.dict;
40
41 if (!(params instanceof _primitives.Dict)) {
42 params = _primitives.Dict.empty;
43 }
44
45 const source = {
46 next() {
47 return str.getByte();
48 }
49
50 };
51 this.ccittFaxDecoder = new _ccitt.CCITTFaxDecoder(source, {
52 K: params.get("K"),
53 EndOfLine: params.get("EndOfLine"),
54 EncodedByteAlign: params.get("EncodedByteAlign"),
55 Columns: params.get("Columns"),
56 Rows: params.get("Rows"),
57 EndOfBlock: params.get("EndOfBlock"),
58 BlackIs1: params.get("BlackIs1")
59 });
60 }
61
62 readBlock() {
63 while (!this.eof) {
64 const c = this.ccittFaxDecoder.readNextChar();
65
66 if (c === -1) {
67 this.eof = true;
68 return;
69 }
70
71 this.ensureBuffer(this.bufferLength + 1);
72 this.buffer[this.bufferLength++] = c;
73 }
74 }
75
76}
77
78exports.CCITTFaxStream = CCITTFaxStream;
\No newline at end of file