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 = undefined;
|
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 | _stream.DecodeStream.call(this, maybeLength);
|
44 | }
|
45 | Jbig2Stream.prototype = Object.create(_stream.DecodeStream.prototype);
|
46 | Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
|
47 | get: function get() {
|
48 | return (0, _util.shadow)(this, 'bytes', this.stream.getBytes(this.maybeLength));
|
49 | },
|
50 |
|
51 | configurable: true
|
52 | });
|
53 | Jbig2Stream.prototype.ensureBuffer = function (requested) {};
|
54 | Jbig2Stream.prototype.readBlock = function () {
|
55 | if (this.eof) {
|
56 | return;
|
57 | }
|
58 | var jbig2Image = new _jbig.Jbig2Image();
|
59 | var chunks = [];
|
60 | if ((0, _primitives.isDict)(this.params)) {
|
61 | var globalsStream = this.params.get('JBIG2Globals');
|
62 | if ((0, _primitives.isStream)(globalsStream)) {
|
63 | var globals = globalsStream.getBytes();
|
64 | chunks.push({
|
65 | data: globals,
|
66 | start: 0,
|
67 | end: globals.length
|
68 | });
|
69 | }
|
70 | }
|
71 | chunks.push({
|
72 | data: this.bytes,
|
73 | start: 0,
|
74 | end: this.bytes.length
|
75 | });
|
76 | var data = jbig2Image.parseChunks(chunks);
|
77 | var dataLength = data.length;
|
78 | for (var i = 0; i < dataLength; i++) {
|
79 | data[i] ^= 0xFF;
|
80 | }
|
81 | this.buffer = data;
|
82 | this.bufferLength = dataLength;
|
83 | this.eof = true;
|
84 | };
|
85 | return Jbig2Stream;
|
86 | }();
|
87 | exports.Jbig2Stream = Jbig2Stream; |
\ | No newline at end of file |