Is there a max size for images being loaded onto c

2019-08-02 11:47发布

问题:

I am building a webapp game that has a scrolling background. The background is just a really tall image that is copied to the smaller canvas in slices to give the sensation of movement. The image file I started with was 6000px tall (my canvas is 640px tall). All desktop browsers and iPad2 (iOS 6) loaded the image file fine and the animation looks great.

However, on iPhone 4S (iOS 5) - the background never loads at all! I solved the problem by just cutting the big background image down until it was under 2000px tall, and there the iPhone finally loaded the graphics onto the canvas and everything works great from there.

So my question is - is there a maximum file size that the javascript canvas.context can handle? Maybe just on certain devices?

I tried all kinds of other work arounds to ensure the file was completely loaded before the JS code ran on the canvas, to no avail.

回答1:

I found this previous post in stack overflow that may answer you question fully.

Maximum size of a <canvas> element