mirror of https://github.com/SixLabors/ImageSharp
8 changed files with 147 additions and 131 deletions
@ -0,0 +1,46 @@ |
|||||
|
// <copyright file="BlackWhiteTest.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp.Tests.Processing.ColorMatrix |
||||
|
{ |
||||
|
using ImageSharp.PixelFormats; |
||||
|
|
||||
|
using Xunit; |
||||
|
|
||||
|
public class BlackWhiteTest : FileTestBase |
||||
|
{ |
||||
|
[Fact] |
||||
|
[WithFileCollection(nameof(AllBmpFiles), StandardPixelTypes)] |
||||
|
public void ImageShouldApplyBlackWhiteFilter<TPixel>(TestImageProvider<TPixel> provider) |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
using (Image<TPixel> image = provider.GetImage()) |
||||
|
{ |
||||
|
image.BlackWhite() |
||||
|
.DebugSave(provider, null, Extensions.Bmp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
[WithFileCollection(nameof(AllBmpFiles), StandardPixelTypes)] |
||||
|
public void ImageShouldApplyBlackWhiteFilterInBox<TPixel>(TestImageProvider<TPixel> provider) |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
using (Image<TPixel> source = provider.GetImage()) |
||||
|
using (var image = new Image<TPixel>(source)) |
||||
|
{ |
||||
|
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
||||
|
|
||||
|
image.BlackWhite(bounds) |
||||
|
.DebugSave(provider, null, Extensions.Bmp); |
||||
|
|
||||
|
// Draw identical shapes over the bounded and compare to ensure changes are constrained.
|
||||
|
image.Fill(NamedColors<TPixel>.HotPink, bounds); |
||||
|
source.Fill(NamedColors<TPixel>.HotPink, bounds); |
||||
|
ImageComparer.CheckSimilarity(image, source); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,60 @@ |
|||||
|
// <copyright file="ColorBlindnessTest.cs" company="James Jackson-South">
|
||||
|
// Copyright (c) James Jackson-South and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
// </copyright>
|
||||
|
|
||||
|
namespace ImageSharp.Tests.Processing.ColorMatrix |
||||
|
{ |
||||
|
using ImageSharp.PixelFormats; |
||||
|
using ImageSharp.Processing; |
||||
|
|
||||
|
using Xunit; |
||||
|
|
||||
|
public class ColorBlindnessTest : FileTestBase |
||||
|
{ |
||||
|
public static readonly TheoryData<ColorBlindness> ColorBlindnessFilters |
||||
|
= new TheoryData<ColorBlindness> |
||||
|
{ |
||||
|
ColorBlindness.Achromatomaly, |
||||
|
ColorBlindness.Achromatopsia, |
||||
|
ColorBlindness.Deuteranomaly, |
||||
|
ColorBlindness.Deuteranopia, |
||||
|
ColorBlindness.Protanomaly, |
||||
|
ColorBlindness.Protanopia, |
||||
|
ColorBlindness.Tritanomaly, |
||||
|
ColorBlindness.Tritanopia |
||||
|
}; |
||||
|
|
||||
|
[Theory] |
||||
|
[WithFileCollection(nameof(AllBmpFiles), nameof(ColorBlindnessFilters), StandardPixelTypes)] |
||||
|
public void ImageShouldApplyColorBlindnessFilter<TPixel>(TestImageProvider<TPixel> provider, ColorBlindness colorBlindness) |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
using (Image<TPixel> image = provider.GetImage()) |
||||
|
{ |
||||
|
image.ColorBlindness(colorBlindness) |
||||
|
.DebugSave(provider, null, Extensions.Bmp); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[WithFileCollection(nameof(AllBmpFiles), nameof(ColorBlindnessFilters), StandardPixelTypes)] |
||||
|
public void ImageShouldApplyColorBlindnessFilterInBox<TPixel>(TestImageProvider<TPixel> provider, ColorBlindness colorBlindness) |
||||
|
where TPixel : struct, IPixel<TPixel> |
||||
|
{ |
||||
|
using (Image<TPixel> source = provider.GetImage()) |
||||
|
using (var image = new Image<TPixel>(source)) |
||||
|
{ |
||||
|
var bounds = new Rectangle(10, 10, image.Width / 2, image.Height / 2); |
||||
|
|
||||
|
image.ColorBlindness(colorBlindness, bounds) |
||||
|
.DebugSave(provider, null, Extensions.Bmp); |
||||
|
|
||||
|
// Draw identical shapes over the bounded and compare to ensure changes are constrained.
|
||||
|
image.Fill(NamedColors<TPixel>.HotPink, bounds); |
||||
|
source.Fill(NamedColors<TPixel>.HotPink, bounds); |
||||
|
ImageComparer.CheckSimilarity(image, source); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,47 +0,0 @@ |
|||||
// <copyright file="BlackWhiteTest.cs" company="James Jackson-South">
|
|
||||
// Copyright (c) James Jackson-South and contributors.
|
|
||||
// Licensed under the Apache License, Version 2.0.
|
|
||||
// </copyright>
|
|
||||
|
|
||||
namespace ImageSharp.Tests |
|
||||
{ |
|
||||
using System.IO; |
|
||||
|
|
||||
using ImageSharp.PixelFormats; |
|
||||
|
|
||||
using Xunit; |
|
||||
|
|
||||
public class BlackWhiteTest : FileTestBase |
|
||||
{ |
|
||||
[Fact] |
|
||||
public void ImageShouldApplyBlackWhiteFilter() |
|
||||
{ |
|
||||
string path = this.CreateOutputDirectory("BlackWhite"); |
|
||||
|
|
||||
foreach (TestFile file in Files) |
|
||||
{ |
|
||||
using (Image<Rgba32> image = file.CreateImage()) |
|
||||
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}")) |
|
||||
{ |
|
||||
image.BlackWhite().Save(output); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public void ImageShouldApplyBlackWhiteFilterInBox() |
|
||||
{ |
|
||||
string path = this.CreateOutputDirectory("BlackWhite"); |
|
||||
|
|
||||
foreach (TestFile file in Files) |
|
||||
{ |
|
||||
string filename = file.GetFileName("-InBox"); |
|
||||
using (Image<Rgba32> image = file.CreateImage()) |
|
||||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|
||||
{ |
|
||||
image.BlackWhite(new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,64 +0,0 @@ |
|||||
// <copyright file="ColorBlindnessTest.cs" company="James Jackson-South">
|
|
||||
// Copyright (c) James Jackson-South and contributors.
|
|
||||
// Licensed under the Apache License, Version 2.0.
|
|
||||
// </copyright>
|
|
||||
|
|
||||
namespace ImageSharp.Tests |
|
||||
{ |
|
||||
using ImageSharp.Processing; |
|
||||
using System.IO; |
|
||||
|
|
||||
using ImageSharp.PixelFormats; |
|
||||
|
|
||||
using Xunit; |
|
||||
|
|
||||
public class ColorBlindnessTest : FileTestBase |
|
||||
{ |
|
||||
public static readonly TheoryData<ColorBlindness> ColorBlindnessFilters |
|
||||
= new TheoryData<ColorBlindness> |
|
||||
{ |
|
||||
ColorBlindness.Achromatomaly, |
|
||||
ColorBlindness.Achromatopsia, |
|
||||
ColorBlindness.Deuteranomaly, |
|
||||
ColorBlindness.Deuteranopia, |
|
||||
ColorBlindness.Protanomaly, |
|
||||
ColorBlindness.Protanopia, |
|
||||
ColorBlindness.Tritanomaly, |
|
||||
ColorBlindness.Tritanopia |
|
||||
}; |
|
||||
|
|
||||
[Theory] |
|
||||
[MemberData(nameof(ColorBlindnessFilters))] |
|
||||
public void ImageShouldApplyColorBlindnessFilter(ColorBlindness colorBlindness) |
|
||||
{ |
|
||||
string path = this.CreateOutputDirectory("ColorBlindness"); |
|
||||
|
|
||||
foreach (TestFile file in Files) |
|
||||
{ |
|
||||
string filename = file.GetFileName(colorBlindness); |
|
||||
using (Image<Rgba32> image = file.CreateImage()) |
|
||||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|
||||
{ |
|
||||
image.ColorBlindness(colorBlindness).Save(output); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
[Theory] |
|
||||
[MemberData(nameof(ColorBlindnessFilters))] |
|
||||
public void ImageShouldApplyBrightnessFilterInBox(ColorBlindness colorBlindness) |
|
||||
{ |
|
||||
string path = this.CreateOutputDirectory("ColorBlindness"); |
|
||||
|
|
||||
foreach (TestFile file in Files) |
|
||||
{ |
|
||||
string filename = file.GetFileName(colorBlindness + "-InBox"); |
|
||||
using (Image<Rgba32> image = file.CreateImage()) |
|
||||
using (FileStream output = File.OpenWrite($"{path}/{filename}")) |
|
||||
{ |
|
||||
image.ColorBlindness(colorBlindness, new Rectangle(10, 10, image.Width / 2, image.Height / 2)).Save(output); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue