<canvas>的最大尺寸元素 [英] Maximum size of a <canvas> element

查看:29
本文介绍了<canvas>的最大尺寸元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个高度为 6001000 像素、宽度为几十或几十万像素的画布元素.但是,经过一定数量的像素(显然未知)后,画布不再显示我用 JS 绘制的形状.

I'm working with a canvas element with a height of 600 to 1000 pixels and a width of several tens or hundreds of thousands of pixels. However, after a certain number of pixels (obviously unknown), the canvas no longer display shapes I draw with JS.

有没有人知道是否有限制?

Does anyone know if there's a limit?

在 Chrome 12 和 Firefox 4 中测试.

Tested both in Chrome 12 and Firefox 4.

推荐答案

10/13/2014 更新

所有经过测试的浏览器都对画布元素的高度/宽度有限制,但许多浏览器也限制了画布元素的总面积.我能够测试的浏览器的限制如下:

All tested browsers have limits to the height/width of canvas elements, but many browsers also limit the total area of the canvas element. The limits are as follows for the browsers I'm able to test:

最大高度/宽度:32,767 像素
最大区域:268,435,456 像素(例如,16,384 x 16,384)

Maximum height/width: 32,767 pixels
Maximum area: 268,435,456 pixels (e.g., 16,384 x 16,384)

最大高度/宽度:32,767 像素
最大区域:472,907,7​​76 像素(例如,22,528 x 20,992)

Maximum height/width: 32,767 pixels
Maximum area: 472,907,776 pixels (e.g., 22,528 x 20,992)

最大高度/宽度:8,192 像素
最大面积:不适用

Maximum height/width: 8,192 pixels
Maximum area: N/A

最大高度/宽度:4,096 像素
最大面积:不适用

Maximum height/width: 4,096 pixels
Maximum area: N/A

我目前无法测试其他浏览器.有关其他限制,请参阅此页面上的其他答案.

I'm not able to test other browsers at this time. Refer to the other answers on this page for additional limits.

超过大多数浏览器的最大长度/宽度/面积会使画布无法使用.(它会忽略任何绘制命令,即使在可用区域也是如此.)IE 和 IE Mobile 将遵循可用空间内的所有绘制命令.

Exceeding the maximum length/width/area on most browsers renders the canvas unusable. (It will ignore any draw commands, even in the usable area.) IE and IE Mobile will honor all draw commands within the usable space.

这篇关于<canvas>的最大尺寸元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆