Just use imageData directly on Gecko
This commit is contained in:
parent
9d2806ec87
commit
18ce3ebaed
30
pdf.js
30
pdf.js
@ -6,6 +6,11 @@
|
|||||||
var ERRORS = 0, WARNINGS = 1, TODOS = 5;
|
var ERRORS = 0, WARNINGS = 1, TODOS = 5;
|
||||||
var verbosity = WARNINGS;
|
var verbosity = WARNINGS;
|
||||||
|
|
||||||
|
var isGecko = false;
|
||||||
|
if (typeof navigator !== 'undefined') {
|
||||||
|
isGecko = navigator.userAgent.indexOf("Gecko/") !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
function log(msg) {
|
function log(msg) {
|
||||||
if (console && console.log)
|
if (console && console.log)
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
@ -5469,19 +5474,26 @@ var CanvasGraphics = (function() {
|
|||||||
// scale the image to the unit square
|
// scale the image to the unit square
|
||||||
ctx.scale(1 / w, -1 / h);
|
ctx.scale(1 / w, -1 / h);
|
||||||
|
|
||||||
|
|
||||||
var tmpCanvas = new this.ScratchCanvas(w, h);
|
var tmpCanvas = new this.ScratchCanvas(w, h);
|
||||||
var tmpCtx = tmpCanvas.getContext('2d');
|
var tmpCtx = tmpCanvas.getContext('2d');
|
||||||
var tmpImgData = tmpCtx.getImageData(0, 0, w, h);
|
var tmpImgData;
|
||||||
|
|
||||||
|
// Gecko doesn't care too much of the shape of imgData, but other browser
|
||||||
|
// do.
|
||||||
|
if (isGecko) {
|
||||||
|
tmpImgData = imgData;
|
||||||
|
} else {
|
||||||
|
tmpImgData = tmpCtx.getImageData(0, 0, w, h);
|
||||||
|
|
||||||
// Copy over the imageData.
|
// Copy over the imageData.
|
||||||
var tmpImgDataPixels = tmpImgData.data;
|
var tmpImgDataPixels = tmpImgData.data;
|
||||||
var len = tmpImgDataPixels.length;
|
var len = tmpImgDataPixels.length;
|
||||||
|
|
||||||
// TODO: There got to be a better way to copy an ImageData array
|
// TODO: There got to be a better way to copy an ImageData array
|
||||||
// then coping over all the bytes one by one :/
|
// then coping over all the bytes one by one :/
|
||||||
while (len--)
|
while (len--)
|
||||||
tmpImgDataPixels[len] = imgData.data[len];
|
tmpImgDataPixels[len] = imgData.data[len];
|
||||||
|
}
|
||||||
|
|
||||||
tmpCtx.putImageData(tmpImgData, 0, 0);
|
tmpCtx.putImageData(tmpImgData, 0, 0);
|
||||||
ctx.drawImage(tmpCanvas, 0, -h);
|
ctx.drawImage(tmpCanvas, 0, -h);
|
||||||
|
@ -85,7 +85,7 @@ var Objects = {
|
|||||||
get: function(objId) {
|
get: function(objId) {
|
||||||
var obj = Objects[objId];
|
var obj = Objects[objId];
|
||||||
if (!obj || !obj.isResolved) {
|
if (!obj || !obj.isResolved) {
|
||||||
throw "Requesting object that isn't resolved yet";
|
throw "Requesting object that isn't resolved yet " + objId;
|
||||||
}
|
}
|
||||||
return obj.data;
|
return obj.data;
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ var WorkerPDFDoc = (function() {
|
|||||||
|
|
||||||
this.pageCache = [];
|
this.pageCache = [];
|
||||||
|
|
||||||
var useWorker = false;
|
var useWorker = true;
|
||||||
|
|
||||||
if (useWorker) {
|
if (useWorker) {
|
||||||
var worker = new Worker("../worker/boot_processor.js");
|
var worker = new Worker("../worker/boot_processor.js");
|
||||||
|
Loading…
Reference in New Issue
Block a user