1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

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 rgbaLength = size * 4;
var buf = new Uint8Array(size * components);
var tempCanvas = new ScratchCanvas(width, height);
var tempCtx = tempCanvas.getContext('2d');
tempCtx.drawImage(img, 0, 0);
var data = tempCtx.getImageData(0, 0, width, height).data;
var tmpCanvas = new ScratchCanvas(width, height);
var tmpCtx = tmpCanvas.getContext('2d');
tmpCtx.drawImage(img, 0, 0);
var data = tmpCtx.getImageData(0, 0, width, height).data;
if (components == 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,
image, inline) {
var promise = new Promise();
var imageDataPromise = 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
// resolved.
Promise.all(promises).then(function(results) {
var image = new PDFImage(xref, res, results[0], inline, results[1]);
Promise.all([imageDataPromise, smaskPromise]).then(function(results) {
var imageData = results[0], smaskData = results[1];
var image = new PDFImage(xref, res, imageData, inline, smaskData);
callback(image);
});
handleImageData(handler, xref, res, image, promise);
handleImageData(handler, xref, res, image, imageDataPromise);
var smask = xref.fetchIfRef(image.dict.get('SMask'));
if (smask)