Fix inverted 1-bit images in SVG backend
This commit is contained in:
parent
3e34eb31d9
commit
58b214eab3
@ -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');
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -119,6 +119,7 @@
|
||||
!issue5084.pdf
|
||||
!issue8960_reduced.pdf
|
||||
!issue5202.pdf
|
||||
!images_1bit_grayscale.pdf
|
||||
!issue5280.pdf
|
||||
!issue5677.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",
|
||||
"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",
|
||||
|
Loading…
Reference in New Issue
Block a user