mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
feat: Rewrite png metadata handling, new VRC metadata (#1311)
* refactor: Move ScreenshotHelper png parsing to PNGHelper, simplify interface * refactor: Fix references to screenshotmanager * fix: Read resolution, not description * refactor: Rewrite/move all png reading logic into new class * refactor: Integrate new metadata helper functions * refactor: Add docs, re-add legacy mods support, change error handling There are no longer specific errors for each metadata type as it was just super unnecessary; A verbose log including the exception/string is now logged to file instead and a generic error is given in the UI. * fix: Show old vrc beta format images They were being treated as a non-image
This commit is contained in:
@@ -33,7 +33,8 @@ namespace VRCX
|
||||
path = newPath;
|
||||
}
|
||||
|
||||
ScreenshotHelper.WritePNGDescription(path, metadataString);
|
||||
ScreenshotHelper.WriteVRCXMetadata(metadataString, path);
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,8 +198,18 @@ namespace VRCX
|
||||
return false;
|
||||
|
||||
await print.SaveAsPngAsync(tempPath);
|
||||
if (ScreenshotHelper.HasTXt(path))
|
||||
ScreenshotHelper.CopyTXt(path, tempPath);
|
||||
|
||||
using var oldPngFile = new PNGFile(path);
|
||||
using var newPngFile = new PNGFile(tempPath);
|
||||
|
||||
// Copy all iTXt chunks to new file
|
||||
var textChunks = oldPngFile.GetChunksOfType(PNGChunkTypeFilter.iTXt);
|
||||
|
||||
for (var i = 0; i < textChunks.Count; i++)
|
||||
{
|
||||
newPngFile.WriteChunk(textChunks[i]);
|
||||
}
|
||||
|
||||
File.Move(tempPath, path, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ public partial class AppApi
|
||||
}
|
||||
}
|
||||
|
||||
metadata.Add("fileResolution", ScreenshotHelper.ReadPNGResolution(path));
|
||||
using var png = new PNGFile(path);
|
||||
metadata.Add("fileResolution", PNGHelper.ReadResolution(png));
|
||||
|
||||
var creationDate = File.GetCreationTime(path);
|
||||
metadata.Add("creationDate", creationDate.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace VRCX
|
||||
path = newPath;
|
||||
}
|
||||
|
||||
ScreenshotHelper.WritePNGDescription(path, metadataString);
|
||||
ScreenshotHelper.WriteVRCXMetadata(path, metadataString);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user