我有一个每像素 8 位的纹理(图像)。我想将它们减少到每像素 4 位,纹理具有 RGBA 格式。对于 mip 映射中的每个级别。每个级别将纹理划分为 mip 级别的幂。当前的问题是我使用以下代码获取扫描线图像。
for (int z = 0; z < depth; z++)
{
for (uint arrayIndex = 0; arrayIndex < layerCount; arrayIndex++)
{
for (int mipLevel = 0; mipLevel < levelCount; mipLevel++)
{
uint mipWidth = Math.Max((width) / ((uint)1 << mipLevel), 1);
uint mipHeight = Math.Max((height) / ((uint)1 << mipLevel), 1);
uint mipSize = mipWidth*mipHeight*4;
byte[] imageData = new byte[mipSize];
Array.Copy(data, imageOffset, imageData, 0, Math.Min(mipSize, data.Length - imageOffset) / 2);
byte[] rgbaData = ConvertImageToRGBA(imageData, formatInfo.format, mipWidth, mipHeight, true);
imageOffset += mipSize;
}
}