很抱歉这个虚拟问题,但我是新来的,我找不到答案。
- 什么是图像步幅?
- 我正在从位帧创建一个缓冲区字节 [](没有问题。)位帧宽度为 1200,位帧高度为 900。所以(我怀疑)缓冲区必须为 1200*900 = 108,0000。但是缓冲区大小是步幅 * 高度 = 432,0000 (4 * 108,0000)。
Stride 计算为bitFrame.PixelWidth * ((bitFrame.Format.BitsPerPixel + 7) / 8);
Then I using bitFrame.CopyPixels(pixels, stride, 0); //(byte[] pixels)
And I have the function of processing current pixel (that is a struct.)
struct pixel {
float r;
float g;
float b;
};
并且还有像素处理功能pixel processPixel(int x, int y)
。我如何在缓冲区中使用此功能?我认为它必须以某种方式这样称呼:
for(int i = 0; i < height; i++) {
for(int j = 0; j < height; j++) {
processPixel(i, j);
// But how could I use this function with my byte[] buffer?
// And what exactly in this buffer?
// (why stride*height = 4*width*height? cause there are 3 values for pixel RGB)
}
}