Fallback to built-in image decoding if the NativeImageDecoder
fails
In particular this means that if 'JpegDecode', in `src/display/api.js`, fails we'll fallback to the built-in JPEG decoder.
This commit is contained in:
parent
2570717e77
commit
76afe1018b
@ -80,11 +80,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
var colorSpace = dict.get('ColorSpace', 'CS');
|
var colorSpace = dict.get('ColorSpace', 'CS');
|
||||||
colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources,
|
colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources,
|
||||||
this.pdfFunctionFactory);
|
this.pdfFunctionFactory);
|
||||||
var numComps = colorSpace.numComps;
|
|
||||||
var decodePromise = this.handler.sendWithPromise('JpegDecode',
|
return this.handler.sendWithPromise('JpegDecode', [
|
||||||
[image.getIR(this.forceDataSchema), numComps]);
|
image.getIR(this.forceDataSchema), colorSpace.numComps
|
||||||
return decodePromise.then(function (message) {
|
]).then(function({ data, width, height, }) {
|
||||||
var data = message.data;
|
|
||||||
return new Stream(data, 0, data.length, image.dict);
|
return new Stream(data, 0, data.length, image.dict);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -27,7 +27,11 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
*/
|
*/
|
||||||
function handleImageData(image, nativeDecoder) {
|
function handleImageData(image, nativeDecoder) {
|
||||||
if (nativeDecoder && nativeDecoder.canDecode(image)) {
|
if (nativeDecoder && nativeDecoder.canDecode(image)) {
|
||||||
return nativeDecoder.decode(image);
|
return nativeDecoder.decode(image).catch((reason) => {
|
||||||
|
warn('Native image decoding failed -- trying to recover: ' +
|
||||||
|
(reason && reason.message));
|
||||||
|
return image;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return Promise.resolve(image);
|
return Promise.resolve(image);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user