|
|
|
@ -3,7 +3,7 @@ |
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Buffers; |
|
|
|
|
|
|
|
using SixLabors.ImageSharp.Advanced; |
|
|
|
using SixLabors.ImageSharp.Memory; |
|
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
|
using SixLabors.ImageSharp.Primitives; |
|
|
|
@ -168,17 +168,31 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing |
|
|
|
{ |
|
|
|
if (!this.Options.Antialias) |
|
|
|
{ |
|
|
|
bool hasOnes = false; |
|
|
|
bool hasZeros = false; |
|
|
|
for (int x = 0; x < scanlineWidth; x++) |
|
|
|
{ |
|
|
|
if (scanline[x] >= 0.5) |
|
|
|
{ |
|
|
|
scanline[x] = 1; |
|
|
|
hasOnes = true; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
scanline[x] = 0; |
|
|
|
hasZeros = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (hasOnes != hasZeros && this.IsSolidBrushWithoutBlending(out SolidBrush<TPixel> solidBrush)) |
|
|
|
{ |
|
|
|
if (hasOnes) |
|
|
|
{ |
|
|
|
source.GetPixelRowSpan(y).Slice(minX, scanlineWidth).Fill(solidBrush.Color); |
|
|
|
} |
|
|
|
|
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
applicator.Apply(scanline, minX, y); |
|
|
|
@ -187,5 +201,17 @@ namespace SixLabors.ImageSharp.Processing.Processors.Drawing |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private bool IsSolidBrushWithoutBlending(out SolidBrush<TPixel> solidBrush) |
|
|
|
{ |
|
|
|
solidBrush = this.Brush as SolidBrush<TPixel>; |
|
|
|
|
|
|
|
if (solidBrush == null) |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
return this.Options.IsOpaqueColorWithoutBlending(solidBrush.Color); |
|
|
|
} |
|
|
|
} |
|
|
|
} |