• 请不要在回答技术问题时复制粘贴 AI 生成的内容
zhfsxtx
V2EX  ›  程序员

html canvas 使用getImageData时,chrome内存飙升,达300多M

  •  
  •   zhfsxtx · Jun 22, 2013 · 3620 views
    This topic created in 4737 days ago, the information mentioned may be changed or developed.
    当我的canvas大小大到2000*4000,使用
    ctx.getImageData(0,0,canvas.width,canvas.height)

    chrome内存会飙升到300多M 有没有什么办法让内存不吃的这么厉害?
    3 replies    1970-01-01 08:00:00 +08:00
    switch
        1
    switch  
       Jun 22, 2013
    2000 * 4000 * 4 = 32000000。
    要么不要使用 getImageData,要么使用 getImageData 时,不要获取整个 canvas 的 ImageData,只获取需要区域的 ImageData。
    zhfsxtx
        2
    zhfsxtx  
    OP
       Jun 22, 2013
    @switch 可以是我就是做获取整个canvas 的ImageData来处理,只获取需要区域的 ImageData?
    难道是要把整个canvas 分成若干个区域,再分开获取,再后拼起来处理?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4177 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 04:12 · PVG 12:12 · LAX 21:12 · JFK 00:12
    ♥ Do have faith in what you're doing.