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.
53 lines
1.5 KiB
53 lines
1.5 KiB
// Copyright (c) Six Labors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
using System.Drawing;
|
|
using System.IO;
|
|
|
|
using BenchmarkDotNet.Attributes;
|
|
|
|
using SixLabors.ImageSharp.PixelFormats;
|
|
|
|
using CoreImage = SixLabors.ImageSharp.Image;
|
|
using CoreSize = SixLabors.ImageSharp.Size;
|
|
|
|
namespace SixLabors.ImageSharp.Benchmarks.Codecs
|
|
{
|
|
public class DecodeTiff : BenchmarkBase
|
|
{
|
|
private byte[] tiffBytes;
|
|
|
|
[GlobalSetup]
|
|
public void ReadImages()
|
|
{
|
|
if (this.tiffBytes == null)
|
|
{
|
|
this.tiffBytes = File.ReadAllBytes("../ImageSharp.Tests/TestImages/Formats/Tiff/Calliphora_rgb_uncompressed.tiff");
|
|
}
|
|
}
|
|
|
|
[Benchmark(Baseline = true, Description = "System.Drawing Tiff")]
|
|
public System.Drawing.Size TiffSystemDrawing()
|
|
{
|
|
using (MemoryStream memoryStream = new MemoryStream(this.tiffBytes))
|
|
{
|
|
using (var image = System.Drawing.Image.FromStream(memoryStream))
|
|
{
|
|
return image.Size;
|
|
}
|
|
}
|
|
}
|
|
|
|
[Benchmark(Description = "ImageSharp Tiff")]
|
|
public CoreSize TiffCore()
|
|
{
|
|
using (MemoryStream memoryStream = new MemoryStream(this.tiffBytes))
|
|
{
|
|
using (Image<Rgba32> image = CoreImage.Load<Rgba32>(memoryStream))
|
|
{
|
|
return new CoreSize(image.Width, image.Height);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|