views:

17

answers:

0

I run this code every frame, works great in chrome

data[index + 0] = bgData[dis + 0];
data[index + 1] = bgData[dis + 1];
data[index + 2] = bgData[dis + 2];
data[index + 3] = 255;

but firefox gives the error:

An invalid or illegal string was specified" code: "12

unless I add -1 to each line as below:

data[index + 0] = bgData[dis + 0] -1;
data[index + 1] = bgData[dis + 1] -1;
data[index + 2] = bgData[dis + 2] -1;
data[index + 3] = 255;

any ideas why this might happen? I am trying to optimize the code as much as possible, and would also like to understand! the data shouldn't be out of range as its obtained by:

bgData = BackgroundCanvasCtx.getImageData(mX, 0, 320, 400).data;

update the line that causes the error is:

overlayImageCanvasCtx.putImageData(imgData, 0, 0);