-
-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added NegateGrayscale to MagickImage.
- Loading branch information
Showing
4 changed files
with
95 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
tests/Magick.NET.Tests/MagickImageTests/TheNegateGrayscaleMethod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
using ImageMagick; | ||
using Xunit; | ||
|
||
namespace Magick.NET.Tests | ||
{ | ||
public partial class MagickImageTests | ||
{ | ||
public class TheNegateGrayscaleMethod | ||
{ | ||
[Fact] | ||
public void ShouldOnlyNegateGrayscale() | ||
{ | ||
using (var image = new MagickImage("xc:white", 2, 1)) | ||
{ | ||
using (var pixels = image.GetPixels()) | ||
{ | ||
var pixel = pixels.GetPixel(1, 0); | ||
pixel.SetChannel(1, 0); | ||
pixel.SetChannel(2, 0); | ||
} | ||
|
||
image.NegateGrayscale(); | ||
|
||
ColorAssert.Equal(MagickColors.Black, image, 0, 0); | ||
ColorAssert.Equal(MagickColors.Red, image, 1, 0); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void ShouldNegateTheSpecifedChannels() | ||
{ | ||
using (var image = new MagickImage("xc:white", 2, 1)) | ||
{ | ||
using (var pixels = image.GetPixels()) | ||
{ | ||
var pixel = pixels.GetPixel(1, 0); | ||
pixel.SetChannel(1, 0); | ||
pixel.SetChannel(2, 0); | ||
} | ||
|
||
image.NegateGrayscale(Channels.Green); | ||
|
||
ColorAssert.Equal(MagickColors.Fuchsia, image, 0, 0); | ||
ColorAssert.Equal(MagickColors.Red, image, 1, 0); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters