I\'m doing a little HTML5 game and, while loading my sprites at the beginning of the map, I do some processing with GetImageData() / looping over all the image / PutImageData().
Have you seen this performance tip?: http://ajaxian.com/archives/canvas-image-data-optimization-tip
They talk about reducing calls to the DOM to increase performance.
So, based on this tip you might try:
var pixel = ctx.getImageData(0, 0, tmpCanvas.width, tmpCanvas.height);
pixelData=pixel.data; // detach the pixel array from DOM
var length = pixelData.length;
for (var i = 0; i < length; i+= 4) {
pixelData[i] = pixelData[i] * ratio;
pixelData[i + 1] = pixelData[i + 1] * ratio;
pixelData[i + 2] = pixelData[i + 2] * ratio;
}
Your .data calls may be slowing you down.