/// <summary> /// Load a Texture2 from a file. /// </summary> /// <returns>The Texture2D.</returns> /// <param name="path">Path to the texture.</param> /// <param name = "config">The texture configuration.</param> public static Texture2D FromFile(string path, TextureConfiguration config) { // Throw if the file doesn't exist if (!File.Exists(path)) { LogExtensions.ThrowStatic("Could not find file '{0}'", path); } Texture2D tex; // Load the image int x = -1, y = -1, n = -1; var data = Stb.Load(path, ref x, ref y, ref n, 4); tex = new Texture2D(config, x, y); tex.SetData(data, null); Stb.Free(data); // Return the texture return(tex); }