Пример #1
0
        public static byte[] GetRgbaImage(ITexture model, int mipMapLevel = 0)
        {
            var x = model.GetTextureData(mipMapLevel);

            switch (model.Format)
            {
            // compressed formats...
            case TextureFormat.D3DFMT_DXT1:
                return(TextureCompressionHelper.DecompressBC1(x, model.Width, model.Height));

            case TextureFormat.D3DFMT_DXT3:
            {
                return(TextureCompressionHelper.DecompressBC2(x, model.Width, model.Height));
            }

            case TextureFormat.D3DFMT_DXT5:
            {
                return(TextureCompressionHelper.DecompressBC3(x, model.Width, model.Height));
            }

            case TextureFormat.D3DFMT_ATI1:
            {
                return(TextureCompressionHelper.DecompressBC4(x, model.Width, model.Height));
            }

            case TextureFormat.D3DFMT_ATI2:
            {
                return(TextureCompressionHelper.DecompressBC5(x, model.Width, model.Height));
            }

            case TextureFormat.D3DFMT_BC7:
            {
                return(TextureCompressionHelper.DecompressBC7(x, model.Width, model.Height));
            }

            // uncompressed formats...
            case TextureFormat.D3DFMT_A8:
            {
                return(TextureConvert.MakeRGBAFromA8(x, model.Width, model.Height));
            }

            case TextureFormat.D3DFMT_L8:
            {
                return(TextureConvert.MakeARGBFromL8(x, model.Width, model.Height));
            }

            case TextureFormat.D3DFMT_A1R5G5B5:
            {
                return(TextureConvert.MakeARGBFromA1R5G5B5(x, model.Width, model.Height));
            }

            case TextureFormat.D3DFMT_A8B8G8R8:
            {
                return(TextureConvert.MakeRGBAFromA8B8G8R8(x, model.Width, model.Height));
            }

            case TextureFormat.D3DFMT_A8R8G8B8:
            {
                return(TextureConvert.MakeRGBAFromA8R8G8B8(x, model.Width, model.Height));
            }

            default:
                throw new System.Exception("unknown format");
            }
        }