将 mip map 级别的 32 位图像转换为 16 位

问题描述 投票:0回答:0

我有一个每像素 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;
                            }
                          
                        }
c# bitmap
© www.soinside.com 2019 - 2024. All rights reserved.