Merge pull request #9206 from janpe2/svg-inv-images
Fix inverted 1-bit images in SVG backend
This commit is contained in:
commit
e320243870
@ -182,7 +182,7 @@ var convertImgDataToPng = (function convertImgDataToPngClosure() {
|
|||||||
return idat;
|
return idat;
|
||||||
}
|
}
|
||||||
|
|
||||||
function encode(imgData, kind, forceDataSchema) {
|
function encode(imgData, kind, forceDataSchema, isMask) {
|
||||||
var width = imgData.width;
|
var width = imgData.width;
|
||||||
var height = imgData.height;
|
var height = imgData.height;
|
||||||
var bitDepth, colorType, lineSize;
|
var bitDepth, colorType, lineSize;
|
||||||
@ -220,8 +220,8 @@ var convertImgDataToPng = (function convertImgDataToPngClosure() {
|
|||||||
offsetLiterals += lineSize;
|
offsetLiterals += lineSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind === ImageKind.GRAYSCALE_1BPP) {
|
if (kind === ImageKind.GRAYSCALE_1BPP && isMask) {
|
||||||
// inverting for B/W
|
// inverting for image masks
|
||||||
offsetLiterals = 0;
|
offsetLiterals = 0;
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
offsetLiterals++; // skipping predictor
|
offsetLiterals++; // skipping predictor
|
||||||
@ -265,10 +265,10 @@ var convertImgDataToPng = (function convertImgDataToPngClosure() {
|
|||||||
return createObjectURL(data, 'image/png', forceDataSchema);
|
return createObjectURL(data, 'image/png', forceDataSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
return function convertImgDataToPng(imgData, forceDataSchema) {
|
return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
|
||||||
var kind = (imgData.kind === undefined ?
|
var kind = (imgData.kind === undefined ?
|
||||||
ImageKind.GRAYSCALE_1BPP : imgData.kind);
|
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 width = imgData.width;
|
||||||
var height = imgData.height;
|
var height = imgData.height;
|
||||||
|
|
||||||
var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
|
var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
|
||||||
var cliprect = this.svgFactory.createElement('svg:rect');
|
var cliprect = this.svgFactory.createElement('svg:rect');
|
||||||
cliprect.setAttributeNS(null, 'x', '0');
|
cliprect.setAttributeNS(null, 'x', '0');
|
||||||
cliprect.setAttributeNS(null, 'y', '0');
|
cliprect.setAttributeNS(null, 'y', '0');
|
||||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -119,6 +119,7 @@
|
|||||||
!issue5084.pdf
|
!issue5084.pdf
|
||||||
!issue8960_reduced.pdf
|
!issue8960_reduced.pdf
|
||||||
!issue5202.pdf
|
!issue5202.pdf
|
||||||
|
!images_1bit_grayscale.pdf
|
||||||
!issue5280.pdf
|
!issue5280.pdf
|
||||||
!issue5677.pdf
|
!issue5677.pdf
|
||||||
!issue5954.pdf
|
!issue5954.pdf
|
||||||
|
BIN
test/pdfs/images_1bit_grayscale.pdf
Normal file
BIN
test/pdfs/images_1bit_grayscale.pdf
Normal file
Binary file not shown.
@ -2017,6 +2017,12 @@
|
|||||||
"type": "eq",
|
"type": "eq",
|
||||||
"about": "Type1 font where Length1/Length2 are several orders of magnitude too large."
|
"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",
|
{ "id": "html5checker",
|
||||||
"file": "pdfs/html5checker.pdf",
|
"file": "pdfs/html5checker.pdf",
|
||||||
"md5": "74bbd80d1e7eb5f2951582233ef9ebab",
|
"md5": "74bbd80d1e7eb5f2951582233ef9ebab",
|
||||||
|
Loading…
Reference in New Issue
Block a user