So on android, when I’m loading images into my app from the gallery I use a native plugin which gives me the file’s location and orientation. Shortly after loading the image into a Texture2D I’d like to save it off again, except in a different location but with the same orientation.
Is there anyway to do this directly from unity?
Here’s the code I use for saving the image currently:
void SaveTextureToFile(Texture2D texture, string fileName)
{
byte[] bytes=texture.EncodeToPNG();
FileStream file = File.Open(Application.persistentDataPath + Path.PathSeparator + fileName, FileMode.OpenOrCreate);
var binary= new BinaryWriter(file);
binary.Write(bytes);
file.Close();
}