Browse Source

Glow, Vignette

pull/232/head
James Jackson-South 9 years ago
parent
commit
a37c86549a
  1. 4
      src/ImageSharp/Processing/Overlays/Glow.cs
  2. 4
      src/ImageSharp/Processing/Overlays/Vignette.cs
  3. 70
      tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs
  4. 70
      tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs
  5. 80
      tests/ImageSharp.Tests/Processors/Filters/GlowTest.cs
  6. 80
      tests/ImageSharp.Tests/Processors/Filters/VignetteTest.cs

4
src/ImageSharp/Processing/Overlays/Glow.cs

@ -5,8 +5,6 @@
namespace ImageSharp
{
using System;
using ImageSharp.PixelFormats;
using Processing.Processors;
@ -158,7 +156,7 @@ namespace ImageSharp
public static Image<TPixel> Glow<TPixel>(this Image<TPixel> source, TPixel color, float radius, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
GlowProcessor<TPixel> processor = new GlowProcessor<TPixel>(color, options) { Radius = radius, };
var processor = new GlowProcessor<TPixel>(color, options) { Radius = radius, };
source.ApplyProcessor(processor, rectangle);
return source;
}

4
src/ImageSharp/Processing/Overlays/Vignette.cs

@ -5,8 +5,6 @@
namespace ImageSharp
{
using System;
using ImageSharp.PixelFormats;
using Processing.Processors;
@ -162,7 +160,7 @@ namespace ImageSharp
public static Image<TPixel> Vignette<TPixel>(this Image<TPixel> source, TPixel color, float radiusX, float radiusY, Rectangle rectangle, GraphicsOptions options)
where TPixel : struct, IPixel<TPixel>
{
VignetteProcessor<TPixel> processor = new VignetteProcessor<TPixel>(color, options) { RadiusX = radiusX, RadiusY = radiusY };
var processor = new VignetteProcessor<TPixel>(color, options) { RadiusX = radiusX, RadiusY = radiusY };
source.ApplyProcessor(processor, rectangle);
return source;
}

70
tests/ImageSharp.Tests/Processing/Overlays/GlowTest.cs

@ -0,0 +1,70 @@
// <copyright file="GlowTest.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.Overlays
{
using ImageSharp.PixelFormats;
using Xunit;
public class GlowTest : FileTestBase
{
[Theory]
[WithFileCollection(nameof(DefaultFiles), StandardPixelType)]
public void ImageShouldApplyGlowFilter<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())
{
image.Glow()
.DebugSave(provider, null, Extensions.Bmp);
}
}
[Theory]
[WithFileCollection(nameof(DefaultFiles), StandardPixelType)]
public void ImageShouldApplyGlowFilterColor<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())
{
image.Glow(NamedColors<TPixel>.Orange)
.DebugSave(provider, null, Extensions.Bmp);
}
}
[Theory]
[WithFileCollection(nameof(DefaultFiles), StandardPixelType)]
public void ImageShouldApplyGlowFilterRadius<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())
{
image.Glow(image.Width / 4F)
.DebugSave(provider, null, Extensions.Bmp);
}
}
[Theory]
[WithFileCollection(nameof(DefaultFiles), StandardPixelType)]
public void ImageShouldApplyGlowFilterInBox<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.Glow(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);
}
}
}
}

70
tests/ImageSharp.Tests/Processing/Overlays/VignetteTest.cs

@ -0,0 +1,70 @@
// <copyright file="VignetteTest.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.Overlays
{
using ImageSharp.PixelFormats;
using Xunit;
public class VignetteTest : FileTestBase
{
[Theory]
[WithFileCollection(nameof(DefaultFiles), StandardPixelType)]
public void ImageShouldApplyVignetteFilter<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())
{
image.Vignette()
.DebugSave(provider, null, Extensions.Bmp);
}
}
[Theory]
[WithFileCollection(nameof(DefaultFiles), StandardPixelType)]
public void ImageShouldApplyVignetteFilterColor<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())
{
image.Vignette(NamedColors<TPixel>.Orange)
.DebugSave(provider, null, Extensions.Bmp);
}
}
[Theory]
[WithFileCollection(nameof(DefaultFiles), StandardPixelType)]
public void ImageShouldApplyVignetteFilterRadius<TPixel>(TestImageProvider<TPixel> provider)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage())
{
image.Vignette(image.Width / 4F, image.Height / 4F)
.DebugSave(provider, null, Extensions.Bmp);
}
}
[Theory]
[WithFileCollection(nameof(DefaultFiles), StandardPixelType)]
public void ImageShouldApplyVignetteFilterInBox<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.Vignette(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);
}
}
}
}

80
tests/ImageSharp.Tests/Processors/Filters/GlowTest.cs

@ -1,80 +0,0 @@
// <copyright file="GlowTest.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 GlowTest : FileTestBase
{
[Fact]
public void ImageShouldApplyGlowFilter()
{
string path = this.CreateOutputDirectory("Glow");
foreach (TestFile file in Files)
{
using (Image<Rgba32> image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}"))
{
image.Glow().Save(output);
}
}
}
[Fact]
public void ImageShouldApplyGlowFilterColor()
{
string path = this.CreateOutputDirectory("Glow");
foreach (TestFile file in Files)
{
string filename = file.GetFileName("Color");
using (Image<Rgba32> image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
image.Glow(Rgba32.HotPink).Save(output);
}
}
}
[Fact]
public void ImageShouldApplyGlowFilterRadius()
{
string path = this.CreateOutputDirectory("Glow");
foreach (TestFile file in Files)
{
string filename = file.GetFileName("Radius");
using (Image<Rgba32> image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
image.Glow(image.Width / 4F).Save(output);
}
}
}
[Fact]
public void ImageShouldApplyGlowFilterInBox()
{
string path = this.CreateOutputDirectory("Glow");
foreach (TestFile file in Files)
{
string filename = file.GetFileName("InBox");
using (Image<Rgba32> image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
image.Glow(new Rectangle(image.Width / 8, image.Height / 8, image.Width / 2, image.Height / 2))
.Save(output);
}
}
}
}
}

80
tests/ImageSharp.Tests/Processors/Filters/VignetteTest.cs

@ -1,80 +0,0 @@
// <copyright file="VignetteTest.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 VignetteTest : FileTestBase
{
[Fact]
public void ImageShouldApplyVignetteFilter()
{
string path = this.CreateOutputDirectory("Vignette");
foreach (TestFile file in Files)
{
using (Image<Rgba32> image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{file.FileName}"))
{
image.Vignette().Save(output);
}
}
}
[Fact]
public void ImageShouldApplyVignetteFilterColor()
{
string path = this.CreateOutputDirectory("Vignette");
foreach (TestFile file in Files)
{
string filename = file.GetFileName("Color");
using (Image<Rgba32> image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
image.Vignette(Rgba32.HotPink).Save(output);
}
}
}
[Fact]
public void ImageShouldApplyVignetteFilterRadius()
{
string path = this.CreateOutputDirectory("Vignette");
foreach (TestFile file in Files)
{
string filename = file.GetFileName("Radius");
using (Image<Rgba32> image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
image.Vignette(image.Width / 4F, image.Height / 4F).Save(output);
}
}
}
[Fact]
public void ImageShouldApplyVignetteFilterInBox()
{
string path = this.CreateOutputDirectory("Vignette");
foreach (TestFile file in Files)
{
string filename = file.GetFileName("InBox");
using (Image<Rgba32> image = file.CreateImage())
using (FileStream output = File.OpenWrite($"{path}/{filename}"))
{
image.Vignette(new Rectangle(image.Width / 4, image.Height / 4, image.Width / 2, image.Height / 2))
.Save(output);
}
}
}
}
}
Loading…
Cancel
Save