Fix print cropping and Linux custom photo path

This commit is contained in:
Natsumi
2025-02-17 13:17:43 +13:00
parent 8ee28ea3ca
commit 60d8d7682f
10 changed files with 44 additions and 26 deletions

View File

@@ -191,7 +191,8 @@ namespace VRCX
var ms = new MemoryStream(bytes);
var print = await Image.LoadAsync(ms);
// validation step to ensure image is actually a print
if (print.Width != 2048 || print.Height != 1440) return false;
if (print.Width != 2048 || print.Height != 1440)
return false;
var point = new Point(64, 69);
var size = new Size(1920, 1080);
@@ -199,14 +200,7 @@ namespace VRCX
print.Mutate(x => x.Crop(rectangle));
await print.SaveAsPngAsync(tempPath);
if (ScreenshotHelper.HasTXt(path))
{
var success = ScreenshotHelper.CopyTXt(path, tempPath);
if (!success)
{
File.Delete(tempPath);
return false;
}
}
ScreenshotHelper.CopyTXt(path, tempPath);
File.Move(tempPath, path, true);
return true;
}

View File

@@ -14,9 +14,16 @@ namespace VRCX
{
public override string AddScreenshotMetadata(string path, string metadataString, string worldId, bool changeFilename = false)
{
var winePrefix = Path.Join(_vrcPrefixPath, "drive_c");
var winePath = path.Substring(3).Replace("\\", "/");
path = Path.Join(winePrefix, winePath);
if (path.Length >= 3 && path[1] == ':' &&
(path[2] == '\\' || path[2] == '/'))
{
var driveLetter = path[0].ToString().ToLower();
var winePrefix = Path.Join(_vrcPrefixPath, $"dosdevices/{driveLetter}:");
var winePath = path[3..]; // remove C:\
path = Path.Join(winePrefix, winePath);
}
path = path.Replace("\\", "/");
var fileName = Path.GetFileNameWithoutExtension(path);
if (!File.Exists(path) || !path.EndsWith(".png") || !fileName.StartsWith("VRChat_"))