diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor{TPixel}.cs index 2e66bb6d70..79247d8ed0 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor{TPixel}.cs @@ -24,6 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation var l8 = default(L8); for (int y = top; y < top + height; y++) { + Span pixelRowSpan = pixels.DangerousGetRowSpan(y); for (int x = left; x < left + width - 1;) { byte byteData = data[offset++]; @@ -32,13 +33,13 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation l8.PackedValue = intensity1; color.FromL8(l8); - pixels[x++, y] = color; + pixelRowSpan[x++] = color; byte intensity2 = (byte)((byteData & 0x0F) * 17); l8.PackedValue = intensity2; color.FromL8(l8); - pixels[x++, y] = color; + pixelRowSpan[x++] = color; } if (isOddWidth) @@ -49,7 +50,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation l8.PackedValue = intensity1; color.FromL8(l8); - pixels[left + width - 1, y] = color; + pixelRowSpan[left + width - 1] = color; } } } diff --git a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor{TPixel}.cs b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor{TPixel}.cs index a4650af5ea..8b635043ec 100644 --- a/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor{TPixel}.cs +++ b/src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor{TPixel}.cs @@ -24,6 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation var l8 = default(L8); for (int y = top; y < top + height; y++) { + Span pixelRowSpan = pixels.DangerousGetRowSpan(y); for (int x = left; x < left + width - 1;) { byte byteData = data[offset++]; @@ -32,13 +33,13 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation l8.PackedValue = intensity1; color.FromL8(l8); - pixels[x++, y] = color; + pixelRowSpan[x++] = color; byte intensity2 = (byte)((15 - (byteData & 0x0F)) * 17); l8.PackedValue = intensity2; color.FromL8(l8); - pixels[x++, y] = color; + pixelRowSpan[x++] = color; } if (isOddWidth) @@ -49,7 +50,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation l8.PackedValue = intensity1; color.FromL8(l8); - pixels[left + width - 1, y] = color; + pixelRowSpan[left + width - 1] = color; } } }