Added image pixel type option

This commit is contained in:
Tretiner 2024-07-28 00:00:10 +05:00
parent 1e533e6420
commit bde95026ce
2 changed files with 16 additions and 4 deletions

View File

@ -0,0 +1,7 @@
namespace SoulstormReplayReader.Core.Enums;
public enum PixelType : byte
{
Argb8888,
Bgra8888
}

View File

@ -44,6 +44,8 @@ public sealed class SsReplayReader(Stream stream) : IDisposable
/// </summary> /// </summary>
public bool CheckForBugs { get; set; } public bool CheckForBugs { get; set; }
public PixelType ImagePixelType { get; set; } = PixelType.Bgra8888;
public ReplayDescriptor Descriptor { get; } = new(); public ReplayDescriptor Descriptor { get; } = new();
public ReplayModel Replay { get; set; } public ReplayModel Replay { get; set; }
public int CurrentTick { get; set; } public int CurrentTick { get; set; }
@ -357,8 +359,10 @@ public sealed class SsReplayReader(Stream stream) : IDisposable
for (var y = height - 1; y >= 0; y--) for (var y = height - 1; y >= 0; y--)
{ {
var line = playerImage.GetLine(y); var line = playerImage.GetLine(y);
_binaryReader.ReadBytes(MemoryMarshal.AsBytes(line)); _binaryReader.ReadBytes(MemoryMarshal.AsBytes(line));
if (ImagePixelType == PixelType.Argb8888)
{
var uintLine = MemoryMarshal.Cast<ReplayColor, uint>(line); var uintLine = MemoryMarshal.Cast<ReplayColor, uint>(line);
for (var x = 0; x < uintLine.Length; x++) for (var x = 0; x < uintLine.Length; x++)
@ -366,6 +370,7 @@ public sealed class SsReplayReader(Stream stream) : IDisposable
} }
} }
} }
}
else _binaryReader.Skip(-8); else _binaryReader.Skip(-8);
return player; return player;