Upload screenshot to gallery

This commit is contained in:
Natsumi
2023-02-27 21:02:55 +13:00
parent a27f3f390e
commit 8b59e0fab1
5 changed files with 106 additions and 16 deletions

View File

@@ -689,11 +689,8 @@ namespace VRCX
public void GetScreenshotMetadata(string path)
{
var fileName = Path.GetFileNameWithoutExtension(path);
const string fileNamePrefix = "VRChat_";
var metadata = new JObject();
if (File.Exists(path) && path.EndsWith(".png") && fileName.StartsWith(fileNamePrefix))
if (File.Exists(path) && path.EndsWith(".png"))
{
string metadataString = null;
var readPNGFailed = false;
@@ -756,9 +753,14 @@ namespace VRCX
metadata.Add("nextFilePath", files[index + 1]);
}
metadata.Add("fileResolution", ScreenshotHelper.ReadPNGResolution(path));
var creationDate = File.GetCreationTime(path);
metadata.Add("creationDate", creationDate.ToString("yyyy-MM-dd HH:mm:ss"));
metadata.Add("fileName", fileName);
metadata.Add("filePath", path);
metadata.Add("fileSize", $"{(new FileInfo(path).Length / 1024f / 1024f).ToString("0.00")} MB");
var fileSizeBytes = new FileInfo(path).Length;
metadata.Add("fileSizeBytes", fileSizeBytes.ToString());
metadata.Add("fileSize", $"{(fileSizeBytes / 1024f / 1024f).ToString("0.00")} MB");
ExecuteAppFunction("displayScreenshotMetadata", metadata.ToString(Formatting.Indented));
}
@@ -775,6 +777,16 @@ namespace VRCX
}
}
public string GetFileBase64(string path)
{
if (File.Exists(path))
{
return Convert.ToBase64String(File.ReadAllBytes(path));
}
return null;
}
private struct XSOMessage
{
public int messageType { get; set; }