我想在 C# 中读取像素的 RGB 值,我尝试使用此处找到的以下代码。
int[] raster = new int[height*width];
var b = tiffreader.ReadRGBAImage(width, height, raster);
for (int i = 0; i < width; ++i)
for (int j = 0; j < height; ++j)
{
int offset = (height - j - 1) * width + i;
color.R = Tiff.GetR(raster[offset]);
color.G = Tiff.GetG(raster[offset]);
color.B = Tiff.GetB(raster[offset]);
}
但是我不知道这个偏移量是什么以及为什么当图像是 2D 时光栅是 1D 的。有人可以帮助我理解上面代码中的偏移和栅格吗?