|
|
|
@ -9,9 +9,8 @@ using BenchmarkDotNet.Attributes; |
|
|
|
|
|
|
|
using SixLabors.ImageSharp.PixelFormats; |
|
|
|
using SixLabors.ImageSharp.Processing; |
|
|
|
using SixLabors.ImageSharp.Processing.Text; |
|
|
|
using SixLabors.ImageSharp.Processing.Drawing; |
|
|
|
using System.Linq; |
|
|
|
using SixLabors.ImageSharp.Processing.Processors.Text; |
|
|
|
|
|
|
|
namespace SixLabors.ImageSharp.Benchmarks |
|
|
|
{ |
|
|
|
@ -21,7 +20,7 @@ namespace SixLabors.ImageSharp.Benchmarks |
|
|
|
{ |
|
|
|
|
|
|
|
[Params(10, 100)] |
|
|
|
public int TextIterations{ get; set; } |
|
|
|
public int TextIterations { get; set; } |
|
|
|
public string TextPhrase { get; set; } = "Hello World"; |
|
|
|
public string TextToRender => string.Join(" ", Enumerable.Repeat(this.TextPhrase, this.TextIterations)); |
|
|
|
|
|
|
|
@ -38,7 +37,7 @@ namespace SixLabors.ImageSharp.Benchmarks |
|
|
|
graphics.SmoothingMode = SmoothingMode.AntiAlias; |
|
|
|
Pen pen = new Pen(System.Drawing.Color.HotPink, 10); |
|
|
|
var font = new Font("Arial", 12, GraphicsUnit.Point); |
|
|
|
graphics.DrawString(TextToRender, font, Brushes.HotPink, new RectangleF(10, 10, 780, 780)); |
|
|
|
graphics.DrawString(TextToRender, font, System.Drawing.Brushes.HotPink, new RectangleF(10, 10, 780, 780)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -50,7 +49,7 @@ namespace SixLabors.ImageSharp.Benchmarks |
|
|
|
using (Image<Rgba32> image = new Image<Rgba32>(800, 800)) |
|
|
|
{ |
|
|
|
var font = SixLabors.Fonts.SystemFonts.CreateFont("Arial", 12); |
|
|
|
image.Mutate(x => x.ApplyProcessor(new Processing.Text.Processors.DrawTextProcessor<Rgba32>(new TextGraphicsOptions(true) { WrapTextWidth = 780 }, TextToRender, font, SixLabors.ImageSharp.Processing.Drawing.Brushes.Brushes.Solid(Rgba32.HotPink), null, new SixLabors.Primitives.PointF(10, 10)))); |
|
|
|
image.Mutate(x => x.ApplyProcessor(new DrawTextProcessor<Rgba32>(new TextGraphicsOptions(true) { WrapTextWidth = 780 }, TextToRender, font, Processing.Brushes.Solid(Rgba32.HotPink), null, new SixLabors.Primitives.PointF(10, 10)))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -60,10 +59,10 @@ namespace SixLabors.ImageSharp.Benchmarks |
|
|
|
using (Image<Rgba32> image = new Image<Rgba32>(800, 800)) |
|
|
|
{ |
|
|
|
var font = SixLabors.Fonts.SystemFonts.CreateFont("Arial", 12); |
|
|
|
image.Mutate(x => DrawTextOldVersion(x, new TextGraphicsOptions(true) { WrapTextWidth = 780 }, TextToRender, font, SixLabors.ImageSharp.Processing.Drawing.Brushes.Brushes.Solid(Rgba32.HotPink), null, new SixLabors.Primitives.PointF(10, 10))); |
|
|
|
image.Mutate(x => DrawTextOldVersion(x, new TextGraphicsOptions(true) { WrapTextWidth = 780 }, TextToRender, font, Processing.Brushes.Solid(Rgba32.HotPink), null, new SixLabors.Primitives.PointF(10, 10))); |
|
|
|
} |
|
|
|
|
|
|
|
IImageProcessingContext<TPixel> DrawTextOldVersion<TPixel>(IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, SixLabors.Fonts.Font font, SixLabors.ImageSharp.Processing.Drawing.Brushes.IBrush<TPixel> brush, SixLabors.ImageSharp.Processing.Drawing.Pens.IPen<TPixel> pen, SixLabors.Primitives.PointF location) |
|
|
|
IImageProcessingContext<TPixel> DrawTextOldVersion<TPixel>(IImageProcessingContext<TPixel> source, TextGraphicsOptions options, string text, SixLabors.Fonts.Font font, IBrush<TPixel> brush, IPen<TPixel> pen, SixLabors.Primitives.PointF location) |
|
|
|
where TPixel : struct, IPixel<TPixel> |
|
|
|
{ |
|
|
|
float dpiX = 72; |
|
|
|
|