Browse Source

Micro-optimization in BinaryThresholdProcessor<TPixel>

pull/1132/head
Sergio Pedri 6 years ago
parent
commit
ec4a56b6b7
  1. 4
      src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs

4
src/ImageSharp/Processing/Processors/Binarization/BinaryThresholdProcessor{TPixel}.cs

@ -3,6 +3,7 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SixLabors.ImageSharp.Advanced;
using SixLabors.ImageSharp.PixelFormats;
@ -87,10 +88,11 @@ namespace SixLabors.ImageSharp.Processing.Processors.Binarization
{
Rgba32 rgba = default;
Span<TPixel> row = this.source.GetPixelRowSpan(y);
ref TPixel rowRef = ref MemoryMarshal.GetReference(row);
for (int x = this.minX; x < this.maxX; x++)
{
ref TPixel color = ref row[x];
ref TPixel color = ref Unsafe.Add(ref rowRef, x);
color.ToRgba32(ref rgba);
// Convert to grayscale using ITU-R Recommendation BT.709 if required

Loading…
Cancel
Save