本文整理汇总了C#中Texture2D.Compress方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.Compress方法的具体用法?C# Texture2D.Compress怎么用?C# Texture2D.Compress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture2D
的用法示例。
在下文中一共展示了Texture2D.Compress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadTexture
//.........这里部分代码省略.........
}
else if (dDSHeader.ddspf.dwFourCC == DDSHeaders.DDSValues.uintDXT5)
{
map = new Texture2D((int)dDSHeader.dwWidth, (int)dDSHeader.dwHeight, TextureFormat.DXT5, mipmap);
map.LoadRawTextureData(LoadRestOfReader(binaryReader));
}
else if (dDSHeader.ddspf.dwFourCC == DDSHeaders.DDSValues.uintDXT2)
{
Debug.Log("[Kopernicus]: DXT2 not supported" + path);
}
else if (dDSHeader.ddspf.dwFourCC == DDSHeaders.DDSValues.uintDXT4)
{
Debug.Log("[Kopernicus]: DXT4 not supported: " + path);
}
else if (dDSHeader.ddspf.dwFourCC == DDSHeaders.DDSValues.uintDX10)
{
Debug.Log("[Kopernicus]: DX10 dds not supported: " + path);
}
else
fourcc = false;
}
if (!fourcc)
{
TextureFormat textureFormat = TextureFormat.ARGB32;
bool ok = true;
if (rgb && (rgb888 /*|| bgr888*/))
{
// RGB or RGBA format
textureFormat = alphapixel
? TextureFormat.RGBA32
: TextureFormat.RGB24;
}
else if (rgb && rgb565)
{
// Nvidia texconv B5G6R5_UNORM
textureFormat = TextureFormat.RGB565;
}
else if (rgb && alphapixel && argb4444)
{
// Nvidia texconv B4G4R4A4_UNORM
textureFormat = TextureFormat.ARGB4444;
}
else if (rgb && alphapixel && rbga4444)
{
textureFormat = TextureFormat.RGBA4444;
}
else if (!rgb && alpha != luminance)
{
// A8 format or Luminance 8
textureFormat = TextureFormat.Alpha8;
}
else
{
ok = false;
Debug.Log("[Kopernicus]: Only DXT1, DXT5, A8, RGB24, RGBA32, RGB565, ARGB4444 and RGBA4444 are supported");
}
if (ok)
{
map = new Texture2D((int)dDSHeader.dwWidth, (int)dDSHeader.dwHeight, textureFormat, mipmap);
map.LoadRawTextureData(LoadRestOfReader(binaryReader));
}
}
if (map != null)
if (upload)
map.Apply(false, unreadable);
}
else
Debug.Log("[Kopernicus]: Bad DDS header.");
}
else
{
map = new Texture2D(2, 2);
byte[] data = LoadWholeFile(path);
if (data == null)
throw new Exception("LoadWholeFile failed");
map.LoadImage(data);
if (compress)
map.Compress(true);
if (upload)
map.Apply(false, unreadable);
}
}
catch (Exception ex)
{
uncaught = false;
Debug.Log("[Kopernicus]: failed to load " + path + " with exception " + ex.Message);
}
if (map == null && uncaught)
{
Debug.Log("[Kopernicus]: failed to load " + path);
}
map.name = path.Remove(0, (KSPUtil.ApplicationRootPath + "GameData/").Length);
}
else
Debug.Log("[Kopernicus]: texture does not exist! " + path);
return map;
}