Browse Source

Fix metadata write byte count discrepancy

pull/165/head
Ionite 1 year ago
parent
commit
93c0d6a56d
No known key found for this signature in database
  1. 5
      StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs

5
StabilityMatrix.Avalonia/Helpers/PngDataHelper.cs

@ -91,8 +91,9 @@ public static class PngDataHelper
private static byte[] BuildTextChunk(string key, string value) private static byte[] BuildTextChunk(string key, string value)
{ {
var textData = $"{key}\0{value}"; var textData = $"{key}\0{value}";
var textDataLength = BitConverter.GetBytes(textData.Length).Reverse(); var dataBytes = Encoding.UTF8.GetBytes(textData);
var textDataBytes = Text.Concat(Encoding.UTF8.GetBytes(textData)).ToArray(); var textDataLength = BitConverter.GetBytes(dataBytes.Length).Reverse();
var textDataBytes = Text.Concat(dataBytes).ToArray();
var crc = BitConverter.GetBytes(Crc32Algorithm.Compute(textDataBytes)); var crc = BitConverter.GetBytes(Crc32Algorithm.Compute(textDataBytes));
return textDataLength.Concat(textDataBytes).Concat(crc).ToArray(); return textDataLength.Concat(textDataBytes).Concat(crc).ToArray();

Loading…
Cancel
Save