var ERRORS = 0, WARNINGS = 1, TODOS = 5;
var verbosity = WARNINGS;
+var isGecko = false;
+if (typeof navigator !== 'undefined') {
+ isGecko = navigator.userAgent.indexOf("Gecko/") !== -1;
+}
+
function log(msg) {
if (console && console.log)
console.log(msg);
// scale the image to the unit square
ctx.scale(1 / w, -1 / h);
-
var tmpCanvas = new this.ScratchCanvas(w, h);
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.
- var tmpImgDataPixels = tmpImgData.data;
- var len = tmpImgDataPixels.length;
+ // Copy over the imageData.
+ var tmpImgDataPixels = tmpImgData.data;
+ var len = tmpImgDataPixels.length;
- // TODO: There got to be a better way to copy an ImageData array
- // then coping over all the bytes one by one :/
- while (len--)
- tmpImgDataPixels[len] = imgData.data[len];
+ // TODO: There got to be a better way to copy an ImageData array
+ // then coping over all the bytes one by one :/
+ while (len--)
+ tmpImgDataPixels[len] = imgData.data[len];
+ }
tmpCtx.putImageData(tmpImgData, 0, 0);
ctx.drawImage(tmpCanvas, 0, -h);