diff --git a/src/ImageSharp/Formats/Png/PngDecoderCore.cs b/src/ImageSharp/Formats/Png/PngDecoderCore.cs index eab80ecd92..065d861e71 100644 --- a/src/ImageSharp/Formats/Png/PngDecoderCore.cs +++ b/src/ImageSharp/Formats/Png/PngDecoderCore.cs @@ -933,10 +933,10 @@ internal sealed class PngDecoderCore : IImageDecoderInternals } Color[] colorTable = new Color[palette.Length / Unsafe.SizeOf()]; - ref Rgb24 paletteBase = ref MemoryMarshal.GetReference(MemoryMarshal.Cast(palette)); + ReadOnlySpan rgbTable = MemoryMarshal.Cast(palette); for (int i = 0; i < colorTable.Length; i++) { - colorTable[i] = new Color(Unsafe.Add(ref paletteBase, (uint)i)); + colorTable[i] = new Color(rgbTable[i]); } if (alpha.Length > 0)