mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.9 KiB
62 lines
1.9 KiB
// Copyright (c) Six Labors and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
using System.IO;
|
|
using System.Numerics;
|
|
|
|
using BenchmarkDotNet.Attributes;
|
|
|
|
using SixLabors.ImageSharp.PixelFormats;
|
|
using SixLabors.ImageSharp.Processing;
|
|
|
|
namespace SixLabors.ImageSharp.Benchmarks
|
|
{
|
|
public class DrawLines : BenchmarkBase
|
|
{
|
|
[Benchmark(Baseline = true, Description = "System.Drawing Draw Lines")]
|
|
public void DrawPathSystemDrawing()
|
|
{
|
|
using (var destination = new Bitmap(800, 800))
|
|
using (var graphics = Graphics.FromImage(destination))
|
|
{
|
|
graphics.InterpolationMode = InterpolationMode.Default;
|
|
graphics.SmoothingMode = SmoothingMode.AntiAlias;
|
|
|
|
using (var pen = new System.Drawing.Pen(System.Drawing.Color.HotPink, 10))
|
|
{
|
|
graphics.DrawLines(pen, new[] {
|
|
new PointF(10, 10),
|
|
new PointF(550, 50),
|
|
new PointF(200, 400)
|
|
});
|
|
}
|
|
|
|
using (var stream = new MemoryStream())
|
|
{
|
|
destination.Save(stream, System.Drawing.Imaging.ImageFormat.Bmp);
|
|
}
|
|
}
|
|
}
|
|
|
|
[Benchmark(Description = "ImageSharp Draw Lines")]
|
|
public void DrawLinesCore()
|
|
{
|
|
using (var image = new Image<Rgba32>(800, 800))
|
|
{
|
|
image.Mutate(x => x.DrawLines(
|
|
Rgba32.HotPink,
|
|
10,
|
|
new Vector2(10, 10),
|
|
new Vector2(550, 50),
|
|
new Vector2(200, 400)));
|
|
|
|
using (var stream = new MemoryStream())
|
|
{
|
|
image.SaveAsBmp(stream);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|