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.
51 lines
1.4 KiB
51 lines
1.4 KiB
// <copyright file="DecodeBmp.cs" company="James Jackson-South">
|
|
// Copyright (c) James Jackson-South and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
// </copyright>
|
|
|
|
namespace ImageSharp.Benchmarks.Image
|
|
{
|
|
using System.Drawing;
|
|
using System.IO;
|
|
|
|
using BenchmarkDotNet.Attributes;
|
|
|
|
using CoreImage = ImageSharp.Image;
|
|
using CoreSize = ImageSharp.Size;
|
|
|
|
public class DecodeBmp : BenchmarkBase
|
|
{
|
|
private byte[] bmpBytes;
|
|
|
|
[Setup]
|
|
public void ReadImages()
|
|
{
|
|
if (this.bmpBytes == null)
|
|
{
|
|
this.bmpBytes = File.ReadAllBytes("../ImageSharp.Tests/TestImages/Formats/Bmp/Car.bmp");
|
|
}
|
|
}
|
|
|
|
[Benchmark(Baseline = true, Description = "System.Drawing Bmp")]
|
|
public Size BmpSystemDrawing()
|
|
{
|
|
using (MemoryStream memoryStream = new MemoryStream(this.bmpBytes))
|
|
{
|
|
using (Image image = Image.FromStream(memoryStream))
|
|
{
|
|
return image.Size;
|
|
}
|
|
}
|
|
}
|
|
|
|
[Benchmark(Description = "ImageSharp Bmp")]
|
|
public CoreSize BmpCore()
|
|
{
|
|
using (MemoryStream memoryStream = new MemoryStream(this.bmpBytes))
|
|
{
|
|
CoreImage image = new CoreImage(memoryStream);
|
|
return new CoreSize(image.Width, image.Height);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|