mirror of https://github.com/SixLabors/ImageSharp
2 changed files with 82 additions and 14 deletions
@ -0,0 +1,51 @@ |
|||
// <copyright file="Crop.cs" company="James Jackson-South">
|
|||
// Copyright (c) James Jackson-South and contributors.
|
|||
// Licensed under the Apache License, Version 2.0.
|
|||
// </copyright>
|
|||
|
|||
namespace ImageSharp.Benchmarks |
|||
{ |
|||
using System.Drawing; |
|||
using System.Drawing.Drawing2D; |
|||
|
|||
using BenchmarkDotNet.Attributes; |
|||
using CoreImage = ImageSharp.Image; |
|||
using CorePoint = ImageSharp.Point; |
|||
using CoreColor = ImageSharp.Color; |
|||
using CoreBrushes = ImageSharp.Drawing.Brushes.Brushes; |
|||
using CorePatternBrush = ImageSharp.Drawing.Brushes.PatternBrush; |
|||
using System.IO; |
|||
|
|||
public class FillWithPattern |
|||
{ |
|||
[Benchmark(Baseline = true, Description = "System.Drawing Fill with Pattern")] |
|||
public void DrawPatternPolygonSystemDrawing() |
|||
{ |
|||
using (Bitmap destination = new Bitmap(800, 800)) |
|||
{ |
|||
using (Graphics graphics = Graphics.FromImage(destination)) |
|||
{ |
|||
graphics.SmoothingMode = SmoothingMode.AntiAlias; |
|||
var brush = new HatchBrush(HatchStyle.BackwardDiagonal, Color.HotPink); |
|||
graphics.FillRectangle(brush, new Rectangle(0,0, 800,800)); // can't find a way to flood fill with a brush
|
|||
} |
|||
using (MemoryStream ms = new MemoryStream()) |
|||
{ |
|||
destination.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[Benchmark(Description = "ImageSharp Fill with Pattern")] |
|||
public void DrawPatternPolygon3Core() |
|||
{ |
|||
CoreImage image = new CoreImage(800, 800); |
|||
image.Fill(CoreBrushes.BackwardDiagonal(CoreColor.HotPink)); |
|||
|
|||
using (MemoryStream ms = new MemoryStream()) |
|||
{ |
|||
image.SaveAsBmp(ms); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue