我目前使用以下内容:
ExampleWrapper
但这似乎有些迟钝。有什么方法可以通过缓冲区数组中的一次读取来创建新的const canvasOneBuffer = new Uint8Array(canvasOneImageData.data.buffer);
// within an x/y loop:
const newPixel1Data0 = canvasOneBuffer[4 * (x + y * canvasOne.width) + 0];
const newPixel1Data1 = canvasOneBuffer[4 * (x + y * canvasOne.width) + 1];
const newPixel1Data2 = canvasOneBuffer[4 * (x + y * canvasOne.width) + 2];
const newPixel1Data3 = canvasOneBuffer[4 * (x + y * canvasOne.width) + 3];
const pixel1Data = new Uint8ClampedArray(4);
pixel1Data[0] = newPixel1Data0;
pixel1Data[1] = newPixel1Data1;
pixel1Data[2] = newPixel1Data2;
pixel1Data[3] = newPixel1Data3;
吗?
答案 0 :(得分:1)
const pixel1Data = canvasOneBuffer.slice(0, 4)
.map(canvasItem => {
// do what ever with canvasItem
});