当前位置: 首页>>代码示例>>C#>>正文


C# ITexture.GetTextureData方法代码示例

本文整理汇总了C#中ITexture.GetTextureData方法的典型用法代码示例。如果您正苦于以下问题:C# ITexture.GetTextureData方法的具体用法?C# ITexture.GetTextureData怎么用?C# ITexture.GetTextureData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITexture的用法示例。


在下文中一共展示了ITexture.GetTextureData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetRgbaImage

        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");
            }
        }
开发者ID:SIXNetworks,项目名称:gta-toolkit,代码行数:56,代码来源:TextureCompression.cs

示例2: SaveTextureData

        public static void SaveTextureData(ITexture texture, string fileName)
        {
            var data = texture.GetTextureData();

            var format = DXGI_FORMAT.DXGI_FORMAT_UNKNOWN;
            switch (texture.Format)
            {
                // compressed
                case TextureFormat.D3DFMT_DXT1: format = DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM; break;
                case TextureFormat.D3DFMT_DXT3: format = DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM; break;
                case TextureFormat.D3DFMT_DXT5: format = DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM; break;
                case TextureFormat.D3DFMT_ATI1: format = DXGI_FORMAT.DXGI_FORMAT_BC4_UNORM; break;
                case TextureFormat.D3DFMT_ATI2: format = DXGI_FORMAT.DXGI_FORMAT_BC5_UNORM; break;
                case TextureFormat.D3DFMT_BC7: format = DXGI_FORMAT.DXGI_FORMAT_BC7_UNORM; break;

                // uncompressed
                case TextureFormat.D3DFMT_A1R5G5B5: format = DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM; break;
                case TextureFormat.D3DFMT_A8: format = DXGI_FORMAT.DXGI_FORMAT_A8_UNORM; break;
                case TextureFormat.D3DFMT_A8B8G8R8: format = DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM; break;
                case TextureFormat.D3DFMT_L8: format = DXGI_FORMAT.DXGI_FORMAT_R8_UNORM; break;
                case TextureFormat.D3DFMT_A8R8G8B8: format = DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM; break;
            }

            DXTexdds.SaveDDSImage(fileName, data, 0, texture.Width, texture.Height, 2 * texture.Width, texture.MipMapLevels, (int)format);
        }
开发者ID:SIXNetworks,项目名称:gta-toolkit,代码行数:25,代码来源:DDSIO.cs

示例3: SaveTextureData

        public static void SaveTextureData(ITexture texture, string fileName)
        {
            var data = texture.GetTextureData();

            var format = DXGI_FORMAT.DXGI_FORMAT_UNKNOWN;
            switch (texture.Format)
            {
                // compressed
                case TextureFormat.D3DFMT_DXT1: format = DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM; break;
                case TextureFormat.D3DFMT_DXT3: format = DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM; break;
                case TextureFormat.D3DFMT_DXT5: format = DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM; break;
                case TextureFormat.D3DFMT_ATI1: format = DXGI_FORMAT.DXGI_FORMAT_BC4_UNORM; break;
                case TextureFormat.D3DFMT_ATI2: format = DXGI_FORMAT.DXGI_FORMAT_BC5_UNORM; break;
                case TextureFormat.D3DFMT_BC7: format = DXGI_FORMAT.DXGI_FORMAT_BC7_UNORM; break;

                // uncompressed
                case TextureFormat.D3DFMT_A1R5G5B5: format = DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM; break;
                case TextureFormat.D3DFMT_A8: format = DXGI_FORMAT.DXGI_FORMAT_A8_UNORM; break;
                case TextureFormat.D3DFMT_A8B8G8R8: format = DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM; break;
                case TextureFormat.D3DFMT_L8: format = DXGI_FORMAT.DXGI_FORMAT_R8_UNORM; break;
                case TextureFormat.D3DFMT_A8R8G8B8: format = DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM; break;
            }

            DirectXTex.ImageStruct img = new DirectXTex.ImageStruct();
            img.Data = data;
            img.Width = texture.Width;
            img.Height = texture.Height;
            img.MipMapLevels = texture.MipMapLevels;
            img.Format = (int)format;

            DirectXTex.DDSIO.WriteDDS(fileName, img);
        }
开发者ID:isti37,项目名称:gta-toolkit,代码行数:32,代码来源:DDSIO.cs


注:本文中的ITexture.GetTextureData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。