diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
index 21d7d8756..db9e90adf 100644
--- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
+++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs
@@ -235,7 +235,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
///
/// Looks up color values and builds the image from de-compressed RLE8 data.
- /// Compresssed RLE8 stream is uncompressed by
+ /// Compresssed RLE8 stream is uncompressed by
///
/// The pixel format.
/// The to assign the palette to.
@@ -249,17 +249,19 @@ namespace SixLabors.ImageSharp.Formats.Bmp
var color = default(TPixel);
var rgba = default(Rgba32);
- using (var buffer = Buffer.CreateClean(width * height))
+ using (var buffer = Buffer2D.CreateClean(width, height))
{
this.UncompressRle8(width, buffer);
for (int y = 0; y < height; y++)
{
int newY = Invert(y, height, inverted);
+ Span bufferRow = buffer.GetRowSpan(y);
Span pixelRow = pixels.GetRowSpan(newY);
+
for (int x = 0; x < width; x++)
{
- rgba.Bgr = Unsafe.As(ref colors[buffer[(y * width) + x] * 4]);
+ rgba.Bgr = Unsafe.As(ref colors[bufferRow[x] * 4]);
color.PackFromRgba32(rgba);
pixelRow[x] = color;
}
@@ -277,7 +279,7 @@ namespace SixLabors.ImageSharp.Formats.Bmp
///
/// The width of the bitmap.
/// Buffer for uncompressed data.
- private void UncompressRle8(int w, Buffer buffer)
+ private void UncompressRle8(int w, Span buffer)
{
byte[] cmd = new byte[2];
int count = 0;