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 _primitives = require("./primitives");
|
30 |
|
31 | var _stream = require("./stream");
|
32 |
|
33 | var _jbig = require("./jbig2");
|
34 |
|
35 | var _util = require("../shared/util");
|
36 |
|
37 | var Jbig2Stream = function Jbig2StreamClosure() {
|
38 | function Jbig2Stream(stream, maybeLength, dict, params) {
|
39 | this.stream = stream;
|
40 | this.maybeLength = maybeLength;
|
41 | this.dict = dict;
|
42 | this.params = params;
|
43 |
|
44 | _stream.DecodeStream.call(this, maybeLength);
|
45 | }
|
46 |
|
47 | Jbig2Stream.prototype = Object.create(_stream.DecodeStream.prototype);
|
48 | Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
|
49 | get: function get() {
|
50 | return (0, _util.shadow)(this, 'bytes', this.stream.getBytes(this.maybeLength));
|
51 | },
|
52 | configurable: true
|
53 | });
|
54 |
|
55 | Jbig2Stream.prototype.ensureBuffer = function (requested) {};
|
56 |
|
57 | Jbig2Stream.prototype.readBlock = function () {
|
58 | if (this.eof) {
|
59 | return;
|
60 | }
|
61 |
|
62 | var jbig2Image = new _jbig.Jbig2Image();
|
63 | var chunks = [];
|
64 |
|
65 | if ((0, _primitives.isDict)(this.params)) {
|
66 | var globalsStream = this.params.get('JBIG2Globals');
|
67 |
|
68 | if ((0, _primitives.isStream)(globalsStream)) {
|
69 | var globals = globalsStream.getBytes();
|
70 | chunks.push({
|
71 | data: globals,
|
72 | start: 0,
|
73 | end: globals.length
|
74 | });
|
75 | }
|
76 | }
|
77 |
|
78 | chunks.push({
|
79 | data: this.bytes,
|
80 | start: 0,
|
81 | end: this.bytes.length
|
82 | });
|
83 | var data = jbig2Image.parseChunks(chunks);
|
84 | var dataLength = data.length;
|
85 |
|
86 | for (var i = 0; i < dataLength; i++) {
|
87 | data[i] ^= 0xFF;
|
88 | }
|
89 |
|
90 | this.buffer = data;
|
91 | this.bufferLength = dataLength;
|
92 | this.eof = true;
|
93 | };
|
94 |
|
95 | return Jbig2Stream;
|
96 | }();
|
97 |
|
98 | exports.Jbig2Stream = Jbig2Stream; |
\ | No newline at end of file |