-
-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Chromaticity to MagickImage that will replace the separate prop…
…erties.
- Loading branch information
Showing
9 changed files
with
182 additions
and
142 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
namespace ImageMagick; | ||
|
||
/// <summary> | ||
/// Chromaticity information. | ||
/// </summary> | ||
public interface IChromaticityInfo | ||
{ | ||
/// <summary> | ||
/// Gets the chromaticity blue primary point. | ||
/// </summary> | ||
IPrimaryInfo Blue { get; } | ||
|
||
/// <summary> | ||
/// Gets the chromaticity green primary point. | ||
/// </summary> | ||
IPrimaryInfo Green { get; } | ||
|
||
/// <summary> | ||
/// Gets the chromaticity red primary point. | ||
/// </summary> | ||
IPrimaryInfo Red { get; } | ||
|
||
/// <summary> | ||
/// Gets the chromaticity white primary point. | ||
/// </summary> | ||
IPrimaryInfo White { get; } | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
namespace ImageMagick; | ||
|
||
/// <summary> | ||
/// PrimaryInfo information. | ||
/// </summary> | ||
public partial class ChromaticityInfo : IChromaticityInfo | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ChromaticityInfo"/> class. | ||
/// </summary> | ||
/// <param name="red">The chromaticity red primary point.</param> | ||
/// <param name="green">The chromaticity green primary point.</param> | ||
/// <param name="blue">The chromaticity blue primary point.</param> | ||
/// <param name="white">The chromaticity white primary point.</param> | ||
public ChromaticityInfo(IPrimaryInfo red, IPrimaryInfo green, IPrimaryInfo blue, IPrimaryInfo white) | ||
{ | ||
Red = red; | ||
Green = green; | ||
Blue = blue; | ||
White = white; | ||
} | ||
|
||
/// <summary> | ||
/// Gets the chromaticity blue primary point. | ||
/// </summary> | ||
public IPrimaryInfo Blue { get; } | ||
|
||
/// <summary> | ||
/// Gets the chromaticity green primary point. | ||
/// </summary> | ||
public IPrimaryInfo Green { get; } | ||
|
||
/// <summary> | ||
/// Gets the chromaticity red primary point. | ||
/// </summary> | ||
public IPrimaryInfo Red { get; } | ||
|
||
/// <summary> | ||
/// Gets the chromaticity white primary point. | ||
/// </summary> | ||
public IPrimaryInfo White { get; } | ||
} |
35 changes: 0 additions & 35 deletions
35
tests/Magick.NET.Tests/MagickImageTests/TheChromaBluePrimaryProperty.cs
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
tests/Magick.NET.Tests/MagickImageTests/TheChromaGreenPrimaryProperty.cs
This file was deleted.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
tests/Magick.NET.Tests/MagickImageTests/TheChromaProperty.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,65 @@ | ||
// 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 TheChromaProperty | ||
{ | ||
[Fact] | ||
public void ShouldHaveTheCorrectDefaultValues() | ||
{ | ||
using var image = new MagickImage(Files.SnakewarePNG); | ||
|
||
Assert.InRange(image.Chromaticity.Red.X, 0.64, 0.641); | ||
Assert.InRange(image.Chromaticity.Red.Y, 0.33, 0.331); | ||
Assert.InRange(image.Chromaticity.Red.Z, 0.00, 0.001); | ||
|
||
Assert.InRange(image.Chromaticity.Blue.X, 0.15, 0.151); | ||
Assert.InRange(image.Chromaticity.Blue.Y, 0.06, 0.061); | ||
Assert.InRange(image.Chromaticity.Blue.Z, 0.00, .001); | ||
|
||
Assert.InRange(image.Chromaticity.Green.X, 0.30, 0.301); | ||
Assert.InRange(image.Chromaticity.Green.Y, 0.60, 0.601); | ||
Assert.InRange(image.Chromaticity.Green.Z, 0.00, 0.001); | ||
|
||
Assert.InRange(image.Chromaticity.White.X, 0.3127, 0.31271); | ||
Assert.InRange(image.Chromaticity.White.Y, 0.329, 0.3291); | ||
Assert.InRange(image.Chromaticity.White.Z, 0.00, 0.001); | ||
} | ||
|
||
[Fact] | ||
public void ShouldHaveTheCorrectValuesWhenChanged() | ||
{ | ||
using var image = new MagickImage(Files.SnakewarePNG); | ||
|
||
var chromaticity = new ChromaticityInfo( | ||
new PrimaryInfo(0.5, 1.0, 1.5), | ||
new PrimaryInfo(0.6, 2.0, 2.5), | ||
new PrimaryInfo(0.7, 3.0, 3.5), | ||
new PrimaryInfo(0.8, 4.0, 4.5)); | ||
|
||
image.Chromaticity = chromaticity; | ||
|
||
Assert.InRange(image.Chromaticity.Red.X, 0.50, 0.501); | ||
Assert.InRange(image.Chromaticity.Red.Y, 1.00, 1.001); | ||
Assert.InRange(image.Chromaticity.Red.Z, 1.50, 1.501); | ||
|
||
Assert.InRange(image.Chromaticity.Green.X, 0.60, 0.601); | ||
Assert.InRange(image.Chromaticity.Green.Y, 2.00, 2.001); | ||
Assert.InRange(image.Chromaticity.Green.Z, 2.50, 2.501); | ||
|
||
Assert.InRange(image.Chromaticity.Blue.X, 0.70, 0.701); | ||
Assert.InRange(image.Chromaticity.Blue.Y, 3.00, 3.001); | ||
Assert.InRange(image.Chromaticity.Blue.Z, 3.50, 3.501); | ||
|
||
Assert.InRange(image.Chromaticity.White.X, 0.80, 0.801); | ||
Assert.InRange(image.Chromaticity.White.Y, 4.00, 4.001); | ||
Assert.InRange(image.Chromaticity.White.Z, 4.50, 4.501); | ||
} | ||
} | ||
} |
35 changes: 0 additions & 35 deletions
35
tests/Magick.NET.Tests/MagickImageTests/TheChromaRedPrimaryProperty.cs
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
tests/Magick.NET.Tests/MagickImageTests/TheChromaWhitePointProperty.cs
This file was deleted.
Oops, something went wrong.