Merge pull request #9327 from Snuffleupagus/JpegStream-DeviceGray-length
Avoid truncating JPEG images with DeviceGray ColourSpaces when using the `src/core/jpg.js` built-in decoder
This commit is contained in:
commit
ad0dc7e89a
@ -546,14 +546,21 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
}
|
}
|
||||||
return imgData;
|
return imgData;
|
||||||
}
|
}
|
||||||
if (this.image instanceof JpegStream && !this.smask && !this.mask &&
|
if (this.image instanceof JpegStream && !this.smask && !this.mask) {
|
||||||
(this.colorSpace.name === 'DeviceGray' ||
|
let imageLength = originalHeight * rowBytes;
|
||||||
this.colorSpace.name === 'DeviceRGB' ||
|
switch (this.colorSpace.name) {
|
||||||
this.colorSpace.name === 'DeviceCMYK')) {
|
case 'DeviceGray':
|
||||||
imgData.kind = ImageKind.RGB_24BPP;
|
// Avoid truncating the image, since `JpegImage.getData`
|
||||||
imgData.data = this.getImageBytes(originalHeight * rowBytes,
|
// will expand the image data when `forceRGB === true`.
|
||||||
drawWidth, drawHeight, true);
|
imageLength *= 3;
|
||||||
return imgData;
|
/* falls through */
|
||||||
|
case 'DeviceRGB':
|
||||||
|
case 'DeviceCMYK':
|
||||||
|
imgData.kind = ImageKind.RGB_24BPP;
|
||||||
|
imgData.data = this.getImageBytes(imageLength,
|
||||||
|
drawWidth, drawHeight, /* forceRGB = */ true);
|
||||||
|
return imgData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1318,7 +1318,8 @@
|
|||||||
"link": true,
|
"link": true,
|
||||||
"firstPage": 2,
|
"firstPage": 2,
|
||||||
"lastPage": 2,
|
"lastPage": 2,
|
||||||
"type": "eq"
|
"type": "eq",
|
||||||
|
"nativeImageDecoderSupport": "none"
|
||||||
},
|
},
|
||||||
{ "id": "issue6071",
|
{ "id": "issue6071",
|
||||||
"file": "pdfs/issue6071.pdf",
|
"file": "pdfs/issue6071.pdf",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user