/* istanbul ignore next */
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
define(["require", "exports", "../base-stream", "../decode-stream", "../graphics/images/jbig2-image", "../pdf-primitives"], function (require, exports, base_stream_1, decode_stream_1, jbig2_image_1, pdf_primitives_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _PdfJbig2Stream = (function (_super) {
__extends(_PdfJbig2Stream, _super);
function _PdfJbig2Stream(stream, maybeLength, params) {
var _this = _super.call(this, maybeLength) || this;
_this.stream = stream;
_this.maybeLength = maybeLength;
_this.params = params;
return _this;
}
Object.defineProperty(_PdfJbig2Stream.prototype, "bytes", {
get: function () {
return this.stream.getBytes(this.maybeLength);
},
enumerable: true,
configurable: true
});
_PdfJbig2Stream.prototype.readBlock = function () {
this.decodeImage();
};
_PdfJbig2Stream.prototype.decodeImage = function (bytes) {
if (this.eof) {
return this.buffer;
}
bytes = bytes || this.bytes;
var jbig2Image = new jbig2_image_1._PdfJbig2Image();
var chunks = [];
if (this.params instanceof pdf_primitives_1._PdfDictionary) {
var globalsStream = this.params.get('JBIG2Globals');
if (globalsStream instanceof base_stream_1._PdfBaseStream) {
var globals = globalsStream.getBytes();
chunks.push({ data: globals, start: 0, end: globals.length });
}
}
chunks.push({ data: bytes, start: 0, end: bytes.length });
var data = jbig2Image._parseChunks(chunks);
var dataLength = data.length;
for (var i = 0; i < dataLength; i++) {
data[i] ^= 0xff;
}
this.buffer = data;
this.bufferLength = dataLength;
this.eof = true;
return this.buffer;
};
return _PdfJbig2Stream;
}(decode_stream_1._PdfDecodeStream));
exports._PdfJbig2Stream = _PdfJbig2Stream;
});
|