/// <summary>
/// 缩放Textur2D
/// </summary>
/// <param name="source"></param>
/// <param name="targetWidth"></param>
/// <param name="targetHeight"></param>
/// <returns></returns>
public static Texture2D ScaleTexture(Texture2D source, float targetWidth, float targetHeight)
{
Texture2D result = new Texture2D((int)targetWidth, (int)targetHeight, source.format, false);
float incX = (1.0f / targetWidth);
float incY = (1.0f / targetHeight);
for (int i = 0; i < result.height; ++i)
{
for (int j = 0; j < result.width; ++j)
{
Color newColor = source.GetPixelBilinear((float)j / (float)result.width, (float)i / (float)result.height);
result.SetPixel(j, i, newColor);
}
}
result.Apply();
return result;
}
08-21
1912

07-20
449
