gpt4 book ai didi

javascript - GetImageData 和多个图像

转载 作者:行者123 更新时间:2023-12-02 17:19:47 25 4
gpt4 key购买 nike

当图像被绘制到 Canvas 中时,如何在js中使用getImageData()? (我分别需要每个图像的数据。)

最佳答案

这是一种方法:

// get the imageData for the second image

context.drawImage(secondImage,0,0);
var imageData2=context.getImageData(0,0,canvas.width,canvas.height);
context.clearRect(0,0,canvas.width,canvas.height);

// get the imageData for the first image

context.drawImage(firstImage,0,0);
var imageData1=context.getImageData(0,0,canvas.width,canvas.height);

// and now redraw the second image back on the canvas

context.drawImage(secondImage,0,0);

关于javascript - GetImageData 和多个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24070660/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com