本文整理汇总了C#中Texture.GetTextureData方法的典型用法代码示例。如果您正苦于以下问题:C# Texture.GetTextureData方法的具体用法?C# Texture.GetTextureData怎么用?C# Texture.GetTextureData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture
的用法示例。
在下文中一共展示了Texture.GetTextureData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decode
internal static Image Decode(Texture texture, int level)
{
var width = texture.GetWidth(level);
var height = texture.GetHeight(level);
var data = texture.GetTextureData(level);
switch(texture.TextureType)
{
case TextureType.DXT1:
data = DXTDecoder.DecodeDXT1(data, (int)width, (int)height);
break;
case TextureType.DXT3:
data = DXTDecoder.DecodeDXT3(data, (int)width, (int)height);
break;
case TextureType.DXT5:
data = DXTDecoder.DecodeDXT5(data, (int)width, (int)height);
break;
case TextureType.A8R8G8B8:
// Nothing to do, the data is already in the format we want it to be
break;
case TextureType.L8:
{
var newData = new byte[data.Length*4];
for (int i = 0; i < data.Length; i++)
{
newData[i*4 + 0] = data[i];
newData[i*4 + 1] = data[i];
newData[i*4 + 2] = data[i];
newData[i*4 + 3] = 255;
}
data = newData;
}
break;
default:
throw new ArgumentOutOfRangeException();
}
var bmp = new Bitmap((int) width, (int) height, PixelFormat.Format32bppArgb);
var rect = new Rectangle(0, 0, (int) width, (int) height);
var bmpdata = bmp.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
Marshal.Copy(data, 0, bmpdata.Scan0, (int) width*(int) height*4);
bmp.UnlockBits(bmpdata);
return bmp;
}