Get working for not real images

This commit is contained in:
Julian Viereck 2011-06-22 10:40:51 +02:00
parent b151516416
commit d99dc718c5
3 changed files with 42 additions and 39 deletions

View file

@ -1,3 +1,24 @@
var ImageCanvasProxyCounter = 0;
function ImageCanvasProxy(width, height) {
this.id = ImageCanvasProxyCounter++;
this.width = width;
this.height = height;
// Using `Uint8ClampedArray` seems to be the type of ImageData - at least
// Firebug tells me so.
this.imgData = {
data: Uint8ClampedArray(width * height * 4)
};
}
ImageCanvasProxy.prototype.putImageData = function(imgData) {
// this.ctx.putImageData(imgData, 0, 0);
}
ImageCanvasProxy.prototype.getCanvas = function() {
return this;
}
function CanvasProxy(width, height) {
var stack = this.$stack = [];
@ -51,6 +72,14 @@ function CanvasProxy(width, height) {
"$showText"
];
this.drawImage = function(canvas, x, y) {
if (canvas instanceof ImageCanvasProxy) {
stack.push(["$drawCanvas", [canvas.imgData, x, y, canvas.width, canvas.height]]);
} else {
throw "unkown type to drawImage";
}
}
function buildFuncCall(name) {
return function() {
// console.log("funcCall", name)