【发布时间】:2018-05-02 15:08:00
【问题描述】:
我正在使用诸如
之类的命令读取图像gl.readPixels(0, 0, gl.width, gl.height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
现在像素在一维数组中的长度为width*height*4。我不确定图像值沿哪个轴折叠?直觉上,我希望它读取每一行,首先向下移动红色列,然后是 G、B、A(我称之为沿宽度折叠,然后是高度折叠,而不是 RGBA)。
例如,如果我想访问图像底部右数第二个像素中的 RED 值,我会使用:
<br>
pixels[width*height-2] (collapse along width, then height, then RGBA)<br>
pixels[width*height-1-height] (collapse along height, then width, then RGBA)<br>
pixels[width*height*4-8] (collapse along RGBA, then width, then height)<br>
或其他顺序。
【问题讨论】:
标签: javascript html image-processing webgl