Address Julian's comments.

This commit is contained in:
Brendan Dahl 2011-12-12 15:09:05 -08:00
parent fcd612e486
commit 94a48cab82
4 changed files with 18 additions and 9 deletions

View File

@ -636,10 +636,10 @@ var PDFDoc = (function PDFDocClosure() {
var size = width * height; var size = width * height;
var rgbaLength = size * 4; var rgbaLength = size * 4;
var buf = new Uint8Array(size * components); var buf = new Uint8Array(size * components);
var tempCanvas = new ScratchCanvas(width, height); var tmpCanvas = new ScratchCanvas(width, height);
var tempCtx = tempCanvas.getContext('2d'); var tmpCtx = tmpCanvas.getContext('2d');
tempCtx.drawImage(img, 0, 0); tmpCtx.drawImage(img, 0, 0);
var data = tempCtx.getImageData(0, 0, width, height).data; var data = tmpCtx.getImageData(0, 0, width, height).data;
if (components == 3) { if (components == 3) {
for (var i = 0, j = 0; i < rgbaLength; i += 4, j += 3) { for (var i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {

View File

@ -84,17 +84,17 @@ var PDFImage = (function PDFImageClosure() {
*/ */
PDFImage.buildImage = function buildImage(callback, handler, xref, res, PDFImage.buildImage = function buildImage(callback, handler, xref, res,
image, inline) { image, inline) {
var promise = new Promise(); var imageDataPromise = new Promise();
var smaskPromise = new Promise(); var smaskPromise = new Promise();
var promises = [promise, smaskPromise];
// 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(promises).then(function(results) { Promise.all([imageDataPromise, smaskPromise]).then(function(results) {
var image = new PDFImage(xref, res, results[0], inline, results[1]); var imageData = results[0], smaskData = results[1];
var image = new PDFImage(xref, res, imageData, inline, smaskData);
callback(image); callback(image);
}); });
handleImageData(handler, xref, res, image, promise); handleImageData(handler, xref, res, image, imageDataPromise);
var smask = xref.fetchIfRef(image.dict.get('SMask')); var smask = xref.fetchIfRef(image.dict.get('SMask'));
if (smask) if (smask)

View File

@ -0,0 +1 @@
http://greenhousechallenge.org/media/item/313/38/About-Stacks.pdf

View File

@ -340,5 +340,13 @@
"link": true, "link": true,
"pageLimit": 3, "pageLimit": 3,
"type": "eq" "type": "eq"
},
{
"id": "aboutstacks",
"file": "pdfs/aboutstacks.pdf",
"md5": "6e7c8416a293ba2d83bc8dd20c6ccf51",
"rounds": 1,
"link": true,
"type": "eq"
} }
] ]