Browse Source

JpegSandbox

af/merge-core
Anton Firszov 10 years ago
parent
commit
306deee67e
  1. 1
      src/ImageSharp46/Formats/Jpg/JpegDecoderCore.cs
  2. 6
      tests/ImageSharp.Tests46/Benchmark/DecodeJpeg.cs
  3. 2
      tests/ImageSharp.Tests46/Formats/Png/PngTests.cs
  4. 1
      tests/ImageSharp.Tests46/ImageSharp.Tests46.csproj
  5. 44
      tests/ImageSharp.Tests46/JpegSandbox.cs
  6. 1
      tests/ImageSharp.Tests46/Processors/Filters/BoxBlurTest.cs

1
src/ImageSharp46/Formats/Jpg/JpegDecoderCore.cs

@ -220,6 +220,7 @@ namespace ImageSharp.Formats
}
}
/// <summary>
/// Decodes the image from the specified this._stream and sets
/// the data to image.

6
tests/ImageSharp.Tests46/Benchmark/DecodeJpeg.cs

@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using ImageSharp.Tests;
using Xunit;
using Xunit.Abstractions;
@ -15,7 +16,7 @@ namespace ImageSharp.Tests46.Benchmark
public class DecodeJpeg
{
private static byte[] jpegBytes = File.ReadAllBytes("../../TestImages/Formats/Jpg/Calliphora.jpg");
private static byte[] jpegBytes = File.ReadAllBytes(TestImages.Jpeg.Calliphora);
private ITestOutputHelper _output;
@ -60,8 +61,9 @@ namespace ImageSharp.Tests46.Benchmark
{
DoBenchmark(times, memoryStream =>
{
CoreImage image = new CoreImage(memoryStream); ;
CoreImage image = new CoreImage(memoryStream);
});
}
}
}

2
tests/ImageSharp.Tests46/Formats/Png/PngTests.cs

@ -13,6 +13,8 @@ namespace ImageSharp.Tests
public class PngTests : FileTestBase
{
[Fact]
public void ImageCanSaveIndexedPng()
{

1
tests/ImageSharp.Tests46/ImageSharp.Tests46.csproj

@ -72,6 +72,7 @@
<Compile Include="Helpers\GuardTests.cs" />
<Compile Include="Image\ImagePropertyTests.cs" />
<Compile Include="Image\PixelAccessorTests.cs" />
<Compile Include="JpegSandbox.cs" />
<Compile Include="Numerics\PointTests.cs" />
<Compile Include="Numerics\RationalTests.cs" />
<Compile Include="Numerics\RectangleTests.cs" />

44
tests/ImageSharp.Tests46/JpegSandbox.cs

@ -0,0 +1,44 @@
using System;
using System.IO;
using ImageSharp.Formats;
using Xunit;
namespace ImageSharp.Tests
{
public class JpegSandbox
{
public const string SandboxOutputDirectory = "_SandboxOutput";
protected string CreateTestOutputFile(string fileName)
{
if (!Directory.Exists(SandboxOutputDirectory))
{
Directory.CreateDirectory(SandboxOutputDirectory);
}
string id = Guid.NewGuid().ToString().Substring(0, 4);
string ext = Path.GetExtension(fileName);
fileName = Path.GetFileNameWithoutExtension(fileName);
return $"{SandboxOutputDirectory}/{fileName}_{id}{ext}";
}
protected Stream CreateOutputStream(string fileName)
{
fileName = CreateTestOutputFile(fileName);
return File.OpenWrite(fileName);
}
[Fact]
public void OpenJpeg_SaveBmp()
{
var image = new TestFile(TestImages.Jpeg.Calliphora).CreateImage();
using (var stream = CreateOutputStream(nameof(OpenJpeg_SaveBmp)+".bmp"))
{
image.Save(stream, new BmpFormat());
}
}
}
}

1
tests/ImageSharp.Tests46/Processors/Filters/BoxBlurTest.cs

@ -9,6 +9,7 @@ namespace ImageSharp.Tests
using Xunit;
public class BoxBlurTest : FileTestBase
{
public static readonly TheoryData<int> BoxBlurValues

Loading…
Cancel
Save