Browse Source

Use GetRowSpan

pull/2134/head
Brian Popow 4 years ago
parent
commit
c7aaf10411
  1. 7
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor{TPixel}.cs
  2. 7
      src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor{TPixel}.cs

7
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/BlackIsZero4TiffColor{TPixel}.cs

@ -24,6 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation
var l8 = default(L8); var l8 = default(L8);
for (int y = top; y < top + height; y++) for (int y = top; y < top + height; y++)
{ {
Span<TPixel> pixelRowSpan = pixels.DangerousGetRowSpan(y);
for (int x = left; x < left + width - 1;) for (int x = left; x < left + width - 1;)
{ {
byte byteData = data[offset++]; byte byteData = data[offset++];
@ -32,13 +33,13 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation
l8.PackedValue = intensity1; l8.PackedValue = intensity1;
color.FromL8(l8); color.FromL8(l8);
pixels[x++, y] = color; pixelRowSpan[x++] = color;
byte intensity2 = (byte)((byteData & 0x0F) * 17); byte intensity2 = (byte)((byteData & 0x0F) * 17);
l8.PackedValue = intensity2; l8.PackedValue = intensity2;
color.FromL8(l8); color.FromL8(l8);
pixels[x++, y] = color; pixelRowSpan[x++] = color;
} }
if (isOddWidth) if (isOddWidth)
@ -49,7 +50,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation
l8.PackedValue = intensity1; l8.PackedValue = intensity1;
color.FromL8(l8); color.FromL8(l8);
pixels[left + width - 1, y] = color; pixelRowSpan[left + width - 1] = color;
} }
} }
} }

7
src/ImageSharp/Formats/Tiff/PhotometricInterpretation/WhiteIsZero4TiffColor{TPixel}.cs

@ -24,6 +24,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation
var l8 = default(L8); var l8 = default(L8);
for (int y = top; y < top + height; y++) for (int y = top; y < top + height; y++)
{ {
Span<TPixel> pixelRowSpan = pixels.DangerousGetRowSpan(y);
for (int x = left; x < left + width - 1;) for (int x = left; x < left + width - 1;)
{ {
byte byteData = data[offset++]; byte byteData = data[offset++];
@ -32,13 +33,13 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation
l8.PackedValue = intensity1; l8.PackedValue = intensity1;
color.FromL8(l8); color.FromL8(l8);
pixels[x++, y] = color; pixelRowSpan[x++] = color;
byte intensity2 = (byte)((15 - (byteData & 0x0F)) * 17); byte intensity2 = (byte)((15 - (byteData & 0x0F)) * 17);
l8.PackedValue = intensity2; l8.PackedValue = intensity2;
color.FromL8(l8); color.FromL8(l8);
pixels[x++, y] = color; pixelRowSpan[x++] = color;
} }
if (isOddWidth) if (isOddWidth)
@ -49,7 +50,7 @@ namespace SixLabors.ImageSharp.Formats.Tiff.PhotometricInterpretation
l8.PackedValue = intensity1; l8.PackedValue = intensity1;
color.FromL8(l8); color.FromL8(l8);
pixels[left + width - 1, y] = color; pixelRowSpan[left + width - 1] = color;
} }
} }
} }

Loading…
Cancel
Save