RGBA理论中像素的索引是什么
What is the index of the pixel in RGBA theory
假设您有一张 128 像素宽 x 128 像素高的图像,它由 32 位整数的一维数组表示。
(Each integer contains the RGBA information for one pixel).
如果像素按行优先顺序排列
(that is, the top row of pixels takes up array indices 0…127, the
second row down is in 128… 255, and so on)
那么x=15,y=22(y=0在顶部)的像素索引是多少?
公式
index = y * width + x
例子
假设您有一张 128 像素宽、128 像素高的图像,它由 32 位整数的一维数组表示。
2831 = 128 * 22 + 15
假设您有一张 128 像素宽 x 128 像素高的图像,它由 32 位整数的一维数组表示。
(Each integer contains the RGBA information for one pixel).
如果像素按行优先顺序排列
(that is, the top row of pixels takes up array indices 0…127, the second row down is in 128… 255, and so on)
那么x=15,y=22(y=0在顶部)的像素索引是多少?
公式
index = y * width + x
例子
假设您有一张 128 像素宽、128 像素高的图像,它由 32 位整数的一维数组表示。
2831 = 128 * 22 + 15