Merge pull request #9206 from janpe2/svg-inv-images

Fix inverted 1-bit images in SVG backend
This commit is contained in:
Tim van der Meij 2017-11-28 22:46:43 +01:00 committed by GitHub
commit e320243870
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 6 deletions

View File

@ -182,7 +182,7 @@ var convertImgDataToPng = (function convertImgDataToPngClosure() {
return idat;
}
function encode(imgData, kind, forceDataSchema) {
function encode(imgData, kind, forceDataSchema, isMask) {
var width = imgData.width;
var height = imgData.height;
var bitDepth, colorType, lineSize;
@ -220,8 +220,8 @@ var convertImgDataToPng = (function convertImgDataToPngClosure() {
offsetLiterals += lineSize;
}
if (kind === ImageKind.GRAYSCALE_1BPP) {
// inverting for B/W
if (kind === ImageKind.GRAYSCALE_1BPP && isMask) {
// inverting for image masks
offsetLiterals = 0;
for (y = 0; y < height; y++) {
offsetLiterals++; // skipping predictor
@ -265,10 +265,10 @@ var convertImgDataToPng = (function convertImgDataToPngClosure() {
return createObjectURL(data, 'image/png', forceDataSchema);
}
return function convertImgDataToPng(imgData, forceDataSchema) {
return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
var kind = (imgData.kind === undefined ?
ImageKind.GRAYSCALE_1BPP : imgData.kind);
return encode(imgData, kind, forceDataSchema);
return encode(imgData, kind, forceDataSchema, isMask);
};
})();
@ -1161,7 +1161,7 @@ SVGGraphics = (function SVGGraphicsClosure() {
var width = imgData.width;
var height = imgData.height;
var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
var cliprect = this.svgFactory.createElement('svg:rect');
cliprect.setAttributeNS(null, 'x', '0');
cliprect.setAttributeNS(null, 'y', '0');

View File

@ -119,6 +119,7 @@
!issue5084.pdf
!issue8960_reduced.pdf
!issue5202.pdf
!images_1bit_grayscale.pdf
!issue5280.pdf
!issue5677.pdf
!issue5954.pdf

Binary file not shown.

View File

@ -2017,6 +2017,12 @@
"type": "eq",
"about": "Type1 font where Length1/Length2 are several orders of magnitude too large."
},
{ "id": "images_1bit_grayscale",
"file": "pdfs/images_1bit_grayscale.pdf",
"md5": "e1c36a19563944891bd30cfc0199d07f",
"rounds": 1,
"type": "eq"
},
{ "id": "html5checker",
"file": "pdfs/html5checker.pdf",
"md5": "74bbd80d1e7eb5f2951582233ef9ebab",