diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs
index eb749efe6..6cb9c6176 100644
--- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs
+++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero1TiffColor{TPixel}.cs
@@ -17,14 +17,15 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation
///
public override void Decode(ReadOnlySpan data, Buffer2D pixels, int left, int top, int width, int height)
{
- var color = default(TPixel);
-
int offset = 0;
+ var colorBlack = default(TPixel);
+ var colorWhite = default(TPixel);
- Color black = Color.Black;
- Color white = Color.White;
+ colorBlack.FromRgba32(Color.Black);
+ colorWhite.FromRgba32(Color.White);
for (int y = top; y < top + height; y++)
{
+ Span pixelRowSpan = pixels.DangerousGetRowSpan(y);
for (int x = left; x < left + width; x += 8)
{
byte b = data[offset++];
@@ -34,9 +35,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation
{
int bit = (b >> (7 - shift)) & 1;
- color.FromRgba32(bit == 0 ? black : white);
-
- pixels[x + shift, y] = color;
+ pixelRowSpan[x + shift] = bit == 0 ? colorBlack : colorWhite;
}
}
}
diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs
index 5f1afe46f..41152ac72 100644
--- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs
+++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero1TiffColor{TPixel}.cs
@@ -16,14 +16,15 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation
///
public override void Decode(ReadOnlySpan data, Buffer2D pixels, int left, int top, int width, int height)
{
- var color = default(TPixel);
-
int offset = 0;
+ var colorBlack = default(TPixel);
+ var colorWhite = default(TPixel);
- Color black = Color.Black;
- Color white = Color.White;
+ colorBlack.FromRgba32(Color.Black);
+ colorWhite.FromRgba32(Color.White);
for (int y = top; y < top + height; y++)
{
+ Span pixelRowSpan = pixels.DangerousGetRowSpan(y);
for (int x = left; x < left + width; x += 8)
{
byte b = data[offset++];
@@ -33,9 +34,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation
{
int bit = (b >> (7 - shift)) & 1;
- color.FromRgba32(bit == 0 ? white : black);
-
- pixels[x + shift, y] = color;
+ pixelRowSpan[x + shift] = bit == 0 ? colorWhite : colorBlack;
}
}
}