/* 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", "../decode-stream", "../graphics/images/jpeg-image"], function (require, exports, decode_stream_1, jpeg_image_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var _PdfJpegStream = (function (_super) {
__extends(_PdfJpegStream, _super);
function _PdfJpegStream(stream, maybeLength, params) {
var _this = _super.call(this, maybeLength) || this;
_this._jpegStreamStart = 0;
_this._needsReprocessing = false;
_this.stream = stream;
_this.params = params;
_this.maybeLength = maybeLength;
return _this;
}
_PdfJpegStream.prototype.readBlock = function () {
this.decodeImage();
};
_PdfJpegStream.prototype.decodeImage = function (bytes) {
if (this.eof) {
return this.buffer;
}
bytes = this.skipUselessBytes(bytes || this.stream.getBytes(this.maybeLength));
var jpegImage = new jpeg_image_1._PdfJpegImage();
jpegImage.parse(bytes);
var data = jpegImage._getData(this.drawWidth, this.drawHeight, this.forceRgba, this.forceRgb, true);
this.buffer = data;
this.bufferLength = data.length;
this.eof = true;
return this.buffer;
};
_PdfJpegStream.prototype.skipUselessBytes = function (data) {
for (var i = 0, ii = data.length - 1; i < ii; i++) {
if (data[i] === 0xff && data[i + 1] === 0xd8) {
if (i > 0) {
data = data.subarray(i);
}
break;
}
}
return data;
};
return _PdfJpegStream;
}(decode_stream_1._PdfDecodeStream));
exports._PdfJpegStream = _PdfJpegStream;
});
|