This repository has been archived by the owner on Sep 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 498
/
Crop.cs
44 lines (39 loc) · 1.46 KB
/
Crop.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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 Crop
{
[Benchmark(Baseline = true, Description = "System.Drawing Crop")]
public Size CropSystemDrawing()
{
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, new Rectangle(0, 0, 100, 100), 0, 0, 100, 100, GraphicsUnit.Pixel);
}
return destination.Size;
}
}
}
[Benchmark(Description = "ImageProcessorCore Crop")]
public CoreSize CropResizeCore()
{
using (CoreImage image = new CoreImage(400, 400))
{
image.Crop(100, 100);
return new CoreSize(image.Width, image.Height);
}
}
}
}