1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | "use strict";
|
23 |
|
24 | Object.defineProperty(exports, "__esModule", {
|
25 | value: true
|
26 | });
|
27 | exports.Jbig2Stream = void 0;
|
28 |
|
29 | var _base_stream = require("./base_stream.js");
|
30 |
|
31 | var _decode_stream = require("./decode_stream.js");
|
32 |
|
33 | var _primitives = require("./primitives.js");
|
34 |
|
35 | var _jbig = require("./jbig2.js");
|
36 |
|
37 | var _util = require("../shared/util.js");
|
38 |
|
39 | class Jbig2Stream extends _decode_stream.DecodeStream {
|
40 | constructor(stream, maybeLength, params) {
|
41 | super(maybeLength);
|
42 | this.stream = stream;
|
43 | this.dict = stream.dict;
|
44 | this.maybeLength = maybeLength;
|
45 | this.params = params;
|
46 | }
|
47 |
|
48 | get bytes() {
|
49 | return (0, _util.shadow)(this, "bytes", this.stream.getBytes(this.maybeLength));
|
50 | }
|
51 |
|
52 | ensureBuffer(requested) {}
|
53 |
|
54 | readBlock() {
|
55 | if (this.eof) {
|
56 | return;
|
57 | }
|
58 |
|
59 | const jbig2Image = new _jbig.Jbig2Image();
|
60 | const chunks = [];
|
61 |
|
62 | if (this.params instanceof _primitives.Dict) {
|
63 | const globalsStream = this.params.get("JBIG2Globals");
|
64 |
|
65 | if (globalsStream instanceof _base_stream.BaseStream) {
|
66 | const globals = globalsStream.getBytes();
|
67 | chunks.push({
|
68 | data: globals,
|
69 | start: 0,
|
70 | end: globals.length
|
71 | });
|
72 | }
|
73 | }
|
74 |
|
75 | chunks.push({
|
76 | data: this.bytes,
|
77 | start: 0,
|
78 | end: this.bytes.length
|
79 | });
|
80 | const data = jbig2Image.parseChunks(chunks);
|
81 | const dataLength = data.length;
|
82 |
|
83 | for (let i = 0; i < dataLength; i++) {
|
84 | data[i] ^= 0xff;
|
85 | }
|
86 |
|
87 | this.buffer = data;
|
88 | this.bufferLength = dataLength;
|
89 | this.eof = true;
|
90 | }
|
91 |
|
92 | }
|
93 |
|
94 | exports.Jbig2Stream = Jbig2Stream; |
\ | No newline at end of file |