本文整理汇总了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");
}
}
示例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);
}
示例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);
}