new-horizons/NewHorizons/Utility/ImageUtilities.cs
Nick J. Connors d721201b0e Forked
Renamed to new horizons, updated to current versions of OWML and Outer Wilds, added BlackHoleBuilder, LavaBuilder, RingBuilder. Added support to modify existing planets with configs.
2021-12-08 00:09:11 -05:00

31 lines
807 B
C#

using System.IO;
using UnityEngine;
namespace NewHorizons.Utility
{
static class ImageUtilities
{
public static Texture2D TintImage(Texture2D image, Color tint)
{
var pixels = image.GetPixels();
for (int i = 0; i < pixels.Length; i++)
{
pixels[i].r *= tint.r;
pixels[i].g *= tint.g;
pixels[i].b *= tint.b;
}
var newImage = new Texture2D(image.width, image.height);
newImage.SetPixels(pixels);
return newImage;
}
public static Texture2D LoadImage(string filepath)
{
Texture2D tex = new Texture2D(2, 2);
tex.LoadRawTextureData(File.ReadAllBytes(filepath));
return tex;
}
}
}