FM/Assets/Test/v1.0/TextureSaver.cs

40 lines
1.4 KiB
C#

using System.IO;
using UnityEngine;
public class TextureSaver
{
public static string NewSaveImage(Texture2D tex, string name, string imgFormat = ".png") //, bool IsGTX = false)
{
byte[] bytes = tex.EncodeToPNG();
var dirPath = "folder path";
if (!Directory.Exists(dirPath))
{
Directory.CreateDirectory(dirPath);
}
Debug.Log(dirPath);
string filePath = Path.Combine(dirPath, "-", name);
File.WriteAllBytes(filePath + imgFormat, B83.Image.PNGTools.ChangePPI(bytes, 300, 300));
return filePath + imgFormat;
/*
if (IsGTX)
{
System.Diagnostics.Process process;
process = System.Diagnostics.Process.Start("GTX4CMD", "print -X \"work.xml\" -I \""+ dirPath + name + ".png" + "\" -A \"" + dirPath + name + ".arx4"+ "\" -R 2514");
Debug.Log("print -X \"work.xml\" -I \"" + dirPath + name + ".png" + "\" -A \"" + dirPath + name + ".arx4" + "\" -R 2514");
process.WaitForExit();
process.Close();
}
/*
string localPath = "PrintingImages/" + SaveLoadPlace.GetOrderID() + "/";
if (!Directory.Exists(localPath))
{
Directory.CreateDirectory(localPath);
}
File.WriteAllBytes(localPath + name + ".png", B83.Image.PNGTools.ChangePPI(bytes, 300, 300));*/
}
}