-
Notifications
You must be signed in to change notification settings - Fork 952
/
ColorBalanceEffect.cs
70 lines (63 loc) · 3.77 KB
/
ColorBalanceEffect.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#if NET9_0_OR_GREATER
namespace System.Drawing.Imaging.Effects;
/// <summary>
/// Adjusts the color balance of an image.
/// </summary>
public class ColorBalanceEffect : Effect
{
private readonly ColorBalanceParams _colorBalanceParams;
/// <summary>
/// Creates a new <see cref="ColorBalanceEffect"/> with the given parameters.
/// </summary>
/// <param name="cyanRed">
/// Integer in the range -100 through 100 that specifies a change in the amount of red in the image. If the value
/// is 0, there is no change. As the value moves from 0 to 100, the amount of red in the image increases and the
/// amount of cyan decreases. As the value moves from 0 to -100, the amount of red in the image decreases and the
/// amount of cyan increases.
/// </param>
/// <param name="magentaGreen">
/// Integer in the range -100 through 100 that specifies a change in the amount of green in the image. If the value
/// is 0, there is no change. As the value moves from 0 to 100, the amount of green in the image increases and the
/// amount of magenta decreases. As the value moves from 0 to -100, the amount of green in the image decreases and
/// and the amount of magenta increases.
/// </param>
/// <param name="yellowBlue">
/// Integer in the range -100 through 100 that specifies a change in the amount of blue in the image. If the value
/// is 0, there is no change. As the value moves from 0 to 100, the amount of blue in the image increases and the
/// amount of yellow decreases. As the value moves from 0 to -100, the amount of blue in the image decreases and
/// the amount of yellow increases.
/// </param>
/// <exception cref="ArgumentException">
/// <paramref name="cyanRed"/>, <paramref name="magentaGreen"/>, or <paramref name="yellowBlue"/> is less than
/// -100 or greater than 100.
/// </exception>
public ColorBalanceEffect(int cyanRed, int magentaGreen, int yellowBlue) : base(PInvoke.ColorBalanceEffectGuid)
{
_colorBalanceParams = new() { cyanRed = cyanRed, magentaGreen = magentaGreen, yellowBlue = yellowBlue };
SetParameters(ref _colorBalanceParams);
}
/// <summary>
/// Integer in the range -100 through 100 that specifies a change in the amount of red in the image. If the value
/// is 0, there is no change. As the value moves from 0 to 100, the amount of red in the image increases and the
/// amount of cyan decreases. As the value moves from 0 to -100, the amount of red in the image decreases and the
/// amount of cyan increases.
/// </summary>
public int CyanRed => _colorBalanceParams.cyanRed;
/// <summary>
/// Integer in the range -100 through 100 that specifies a change in the amount of green in the image. If the value
/// is 0, there is no change. As the value moves from 0 to 100, the amount of green in the image increases and the
/// amount of magenta decreases. As the value moves from 0 to -100, the amount of green in the image decreases and
/// and the amount of magenta increases.
/// </summary>
public int MagentaGreen => _colorBalanceParams.magentaGreen;
/// <summary>
/// Integer in the range -100 through 100 that specifies a change in the amount of blue in the image. If the value
/// is 0, there is no change. As the value moves from 0 to 100, the amount of blue in the image increases and the
/// amount of yellow decreases. As the value moves from 0 to -100, the amount of blue in the image decreases and
/// the amount of yellow increases.
/// </summary>
public int YellowBlue => _colorBalanceParams.yellowBlue;
}
#endif