commit
a32d875cc3
@ -226,8 +226,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
insertDependency([objId]);
|
insertDependency([objId]);
|
||||||
args = [objId, w, h];
|
args = [objId, w, h];
|
||||||
|
|
||||||
var softMask = dict.get('SMask', 'IM') || false;
|
var softMask = dict.get('SMask', 'SM') || false;
|
||||||
if (!softMask && image instanceof JpegStream &&
|
var mask = dict.get('Mask') || false;
|
||||||
|
|
||||||
|
if (!softMask && !mask && image instanceof JpegStream &&
|
||||||
image.isNativelySupported(xref, resources)) {
|
image.isNativelySupported(xref, resources)) {
|
||||||
// These JPEGs don't need any more processing so we can just send it.
|
// These JPEGs don't need any more processing so we can just send it.
|
||||||
fn = 'paintJpegXObject';
|
fn = 'paintJpegXObject';
|
||||||
|
51
src/image.js
51
src/image.js
@ -33,7 +33,7 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
// Clamp the value to the range
|
// Clamp the value to the range
|
||||||
return value < 0 ? 0 : value > max ? max : value;
|
return value < 0 ? 0 : value > max ? max : value;
|
||||||
}
|
}
|
||||||
function PDFImage(xref, res, image, inline, smask) {
|
function PDFImage(xref, res, image, inline, smask, mask) {
|
||||||
this.image = image;
|
this.image = image;
|
||||||
if (image.getParams) {
|
if (image.getParams) {
|
||||||
// JPX/JPEG2000 streams directly contain bits per component
|
// JPX/JPEG2000 streams directly contain bits per component
|
||||||
@ -94,12 +94,10 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var mask = dict.get('Mask');
|
if (smask) {
|
||||||
|
|
||||||
if (mask) {
|
|
||||||
TODO('masked images');
|
|
||||||
} else if (smask) {
|
|
||||||
this.smask = new PDFImage(xref, res, smask, false);
|
this.smask = new PDFImage(xref, res, smask, false);
|
||||||
|
} else if (mask) {
|
||||||
|
this.mask = new PDFImage(xref, res, mask, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -110,21 +108,36 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
res, image, inline) {
|
res, image, inline) {
|
||||||
var imageDataPromise = new Promise();
|
var imageDataPromise = new Promise();
|
||||||
var smaskPromise = new Promise();
|
var smaskPromise = new Promise();
|
||||||
|
var maskPromise = new Promise();
|
||||||
// The image data and smask data may not be ready yet, wait till both are
|
// The image data and smask data may not be ready yet, wait till both are
|
||||||
// resolved.
|
// resolved.
|
||||||
Promise.all([imageDataPromise, smaskPromise]).then(function(results) {
|
Promise.all([imageDataPromise, smaskPromise, maskPromise]).then(
|
||||||
var imageData = results[0], smaskData = results[1];
|
function(results) {
|
||||||
var image = new PDFImage(xref, res, imageData, inline, smaskData);
|
var imageData = results[0], smaskData = results[1], maskData = results[2];
|
||||||
|
var image = new PDFImage(xref, res, imageData, inline, smaskData,
|
||||||
|
maskData);
|
||||||
callback(image);
|
callback(image);
|
||||||
});
|
});
|
||||||
|
|
||||||
handleImageData(handler, xref, res, image, imageDataPromise);
|
handleImageData(handler, xref, res, image, imageDataPromise);
|
||||||
|
|
||||||
var smask = image.dict.get('SMask');
|
var smask = image.dict.get('SMask');
|
||||||
if (smask)
|
var mask = image.dict.get('Mask');
|
||||||
|
|
||||||
|
if (smask) {
|
||||||
handleImageData(handler, xref, res, smask, smaskPromise);
|
handleImageData(handler, xref, res, smask, smaskPromise);
|
||||||
else
|
maskPromise.resolve(null);
|
||||||
|
} else {
|
||||||
smaskPromise.resolve(null);
|
smaskPromise.resolve(null);
|
||||||
|
if (mask && isStream(mask)) {
|
||||||
|
handleImageData(handler, xref, res, mask, maskPromise);
|
||||||
|
} else if (mask) {
|
||||||
|
TODO('handle color key masking');
|
||||||
|
maskPromise.resolve(null);
|
||||||
|
} else {
|
||||||
|
maskPromise.resolve(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -268,6 +281,7 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
},
|
},
|
||||||
getOpacity: function PDFImage_getOpacity(width, height) {
|
getOpacity: function PDFImage_getOpacity(width, height) {
|
||||||
var smask = this.smask;
|
var smask = this.smask;
|
||||||
|
var mask = this.mask;
|
||||||
var originalWidth = this.width;
|
var originalWidth = this.width;
|
||||||
var originalHeight = this.height;
|
var originalHeight = this.height;
|
||||||
var buf;
|
var buf;
|
||||||
@ -278,7 +292,20 @@ var PDFImage = (function PDFImageClosure() {
|
|||||||
buf = new Uint8Array(sw * sh);
|
buf = new Uint8Array(sw * sh);
|
||||||
smask.fillGrayBuffer(buf);
|
smask.fillGrayBuffer(buf);
|
||||||
if (sw != width || sh != height)
|
if (sw != width || sh != height)
|
||||||
buf = PDFImage.resize(buf, smask.bps, 1, sw, sh, width, height);
|
buf = PDFImage.resize(buf, smask.bpc, 1, sw, sh, width, height);
|
||||||
|
} else if (mask) {
|
||||||
|
var sw = mask.width;
|
||||||
|
var sh = mask.height;
|
||||||
|
buf = new Uint8Array(sw * sh);
|
||||||
|
mask.numComps = 1;
|
||||||
|
mask.fillGrayBuffer(buf);
|
||||||
|
|
||||||
|
// Need to invert values in buffer
|
||||||
|
for (var i = 0, ii = sw * sh; i < ii; ++i)
|
||||||
|
buf[i] = 255 - buf[i];
|
||||||
|
|
||||||
|
if (sw != width || sh != height)
|
||||||
|
buf = PDFImage.resize(buf, mask.bpc, 1, sw, sh, width, height);
|
||||||
} else {
|
} else {
|
||||||
buf = new Uint8Array(width * height);
|
buf = new Uint8Array(width * height);
|
||||||
for (var i = 0, ii = width * height; i < ii; ++i)
|
for (var i = 0, ii = width * height; i < ii; ++i)
|
||||||
|
1
test/pdfs/issue1796.pdf.link
Normal file
1
test/pdfs/issue1796.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
http://www.maxims6n.bget.ru/book3/viewer/t4.pdf
|
@ -608,5 +608,13 @@
|
|||||||
"md5": "cbc1988e4803f647fa83467a85f0e231",
|
"md5": "cbc1988e4803f647fa83467a85f0e231",
|
||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{ "id": "issue1796",
|
||||||
|
"file": "pdfs/issue1796.pdf",
|
||||||
|
"md5": "9b9b60dc2a4cc3ea05932785d71304fe",
|
||||||
|
"rounds": 1,
|
||||||
|
"pageLimit": 2,
|
||||||
|
"link": true,
|
||||||
|
"type": "eq"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user