Replace ImageCanvas by ScratchCanvas
This commit is contained in:
parent
b17bf4b20e
commit
c9c24ee5c3
39
pdf.js
39
pdf.js
@ -2269,21 +2269,18 @@ var Encodings = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function ImageCanvas(width, height) {
|
function ScratchCanvas(width, height) {
|
||||||
var tmpCanvas = this.canvas = document.createElement("canvas");
|
var canvas = document.createElement("canvas");
|
||||||
tmpCanvas.width = width;
|
canvas.width = width;
|
||||||
tmpCanvas.height = height;
|
canvas.height = height;
|
||||||
|
|
||||||
this.ctx = tmpCanvas.getContext("2d");
|
this.getContext = function(kind) {
|
||||||
this.imgData = this.ctx.getImageData(0, 0, width, height);
|
return canvas.getContext(kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageCanvas.prototype.putImageData = function(imgData) {
|
this.getCanvas = function() {
|
||||||
this.ctx.putImageData(imgData, 0, 0);
|
return canvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageCanvas.prototype.getCanvas = function() {
|
|
||||||
return this.canvas;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var CanvasGraphics = (function() {
|
var CanvasGraphics = (function() {
|
||||||
@ -2294,7 +2291,7 @@ var CanvasGraphics = (function() {
|
|||||||
this.pendingClip = null;
|
this.pendingClip = null;
|
||||||
this.res = null;
|
this.res = null;
|
||||||
this.xobjs = null;
|
this.xobjs = null;
|
||||||
this.ImageCanvas = imageCanvas || ImageCanvas;
|
this.ScratchCanvas = imageCanvas || ScratchCanvas;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
@ -3348,15 +3345,9 @@ var CanvasGraphics = (function() {
|
|||||||
// handle matte object
|
// handle matte object
|
||||||
}
|
}
|
||||||
|
|
||||||
var tmpCanvas = new this.ImageCanvas(w, h);
|
var tmpCanvas = new this.ScratchCanvas(w, h);
|
||||||
// var tmpCanvas = document.createElement("canvas");
|
var tmpCtx = tmpCanvas.getContext("2d");
|
||||||
// tmpCanvas.width = w;
|
var imgData = tmpCtx.getImageData(0, 0, w, h);
|
||||||
// tmpCanvas.height = h;
|
|
||||||
//
|
|
||||||
// var tmpCtx = tmpCanvas.getContext("2d");
|
|
||||||
// var imgData = tmpCtx.getImageData(0, 0, w, h);
|
|
||||||
// var pixels = imgData.data;
|
|
||||||
var imgData = tmpCanvas.imgData;
|
|
||||||
var pixels = imgData.data;
|
var pixels = imgData.data;
|
||||||
|
|
||||||
if (bitsPerComponent != 8)
|
if (bitsPerComponent != 8)
|
||||||
@ -3423,7 +3414,7 @@ var CanvasGraphics = (function() {
|
|||||||
TODO("Images with "+ numComps + " components per pixel");
|
TODO("Images with "+ numComps + " components per pixel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmpCanvas.putImageData(imgData, 0, 0);
|
tmpCtx.putImageData(imgData, 0, 0);
|
||||||
ctx.drawImage(tmpCanvas.getCanvas(), 0, -h);
|
ctx.drawImage(tmpCanvas.getCanvas(), 0, -h);
|
||||||
this.restore();
|
this.restore();
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user