Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static Texture2D LoadFromFile(string filePath)
- {
- if (!filePath.EndsWith(".png")) { throw new ArgumentException("Tried to load an image that was not a PNG.", "filePath"); }
- if (!File.Exists(filePath)) { throw new FileNotFoundException(string.Format("The file at {0} does not exist.")); }
- using (Stream stream = File.OpenRead(filePath))
- {
- return Texture2D.FromStream(GameServices.Graphics, stream);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement