Added image pixel type option
This commit is contained in:
parent
1e533e6420
commit
bde95026ce
7
SoulstormReplayReader.Core/Enums/PixelType.cs
Normal file
7
SoulstormReplayReader.Core/Enums/PixelType.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace SoulstormReplayReader.Core.Enums;
|
||||||
|
|
||||||
|
public enum PixelType : byte
|
||||||
|
{
|
||||||
|
Argb8888,
|
||||||
|
Bgra8888
|
||||||
|
}
|
||||||
@ -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,12 +359,15 @@ 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));
|
||||||
var uintLine = MemoryMarshal.Cast<ReplayColor, uint>(line);
|
|
||||||
|
|
||||||
for (var x = 0; x < uintLine.Length; x++)
|
if (ImagePixelType == PixelType.Argb8888)
|
||||||
uintLine[x] = BinaryPrimitives.ReverseEndianness(uintLine[x]);
|
{
|
||||||
|
var uintLine = MemoryMarshal.Cast<ReplayColor, uint>(line);
|
||||||
|
|
||||||
|
for (var x = 0; x < uintLine.Length; x++)
|
||||||
|
uintLine[x] = BinaryPrimitives.ReverseEndianness(uintLine[x]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user