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.
44 lines
1.4 KiB
44 lines
1.4 KiB
namespace ImageProcessorCore.Benchmarks
|
|
{
|
|
using System.Drawing;
|
|
using System.Drawing.Drawing2D;
|
|
|
|
using BenchmarkDotNet.Attributes;
|
|
|
|
using ImageProcessorCore.Samplers;
|
|
using CoreImage = ImageProcessorCore.Image;
|
|
using CoreSize = ImageProcessorCore.Size;
|
|
|
|
public class Resize
|
|
{
|
|
[Benchmark(Baseline = true, Description = "System.Drawing Resize")]
|
|
public Size ResizeSystemDrawing()
|
|
{
|
|
using (Bitmap source = new Bitmap(400, 400))
|
|
{
|
|
using (Bitmap destination = new Bitmap(100, 100))
|
|
{
|
|
using (Graphics graphics = Graphics.FromImage(destination))
|
|
{
|
|
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
|
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
|
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
|
graphics.DrawImage(source, 0, 0, 100, 100);
|
|
}
|
|
|
|
return destination.Size;
|
|
}
|
|
}
|
|
}
|
|
|
|
[Benchmark(Description = "ImageProcessorCore Resize")]
|
|
public CoreSize ResizeCore()
|
|
{
|
|
using (CoreImage image = new CoreImage(400, 400))
|
|
{
|
|
image.Resize(100, 100);
|
|
return new CoreSize(image.Width, image.Height);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|