Browse Source

Avoid calculating the row start index inside the loop

af/merge-core
Brian Popow 6 years ago
parent
commit
81ed8ca8e2
  1. 6
      src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs

6
src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs

@ -387,9 +387,10 @@ namespace SixLabors.ImageSharp.Formats.Bmp
if (rowHasUndefinedPixels)
{
// Slow path with undefined pixels.
int rowStartIdx = y * width * 3;
for (int x = 0; x < width; x++)
{
int idx = (y * width * 3) + (x * 3);
int idx = rowStartIdx + (x * 3);
if (undefinedPixels[x, y])
{
switch (this.options.RleSkippedPixelHandling)
@ -418,9 +419,10 @@ namespace SixLabors.ImageSharp.Formats.Bmp
else
{
// Fast path without any undefined pixels.
int rowStartIdx = y * width * 3;
for (int x = 0; x < width; x++)
{
int idx = (y * width * 3) + (x * 3);
int idx = rowStartIdx + (x * 3);
color.FromBgr24(Unsafe.As<byte, Bgr24>(ref bufferSpan[idx]));
pixelRow[x] = color;
}

Loading…
Cancel
Save