diff --git a/project/code/LGS/Database/Chunks/WorldRep.cs b/project/code/LGS/Database/Chunks/WorldRep.cs index cc61d6f..ef442e4 100644 --- a/project/code/LGS/Database/Chunks/WorldRep.cs +++ b/project/code/LGS/Database/Chunks/WorldRep.cs @@ -154,10 +154,10 @@ public class WorldRep : IChunk ArgumentOutOfRangeException.ThrowIfLessThan(layer, 0, nameof(layer)); ArgumentOutOfRangeException.ThrowIfGreaterThan(layer, Layers, nameof(layer)); - var pixelCount = Width * Height; - var pIdx = layer * Bpp * pixelCount; - var bytes = new byte[pixelCount * 4]; - for (var i = 0; i < pixelCount; i += 4, pIdx += Bpp) + var pIdx = layer * Bpp * Width * Height; + var length = 4 * Width * Height; + var bytes = new byte[length]; + for (var i = 0; i < length; i += 4, pIdx += Bpp) { switch (Bpp) {