Class MagickColor
- Namespace
- ImageMagick
- Assembly
- Magick.NET-Q16-AnyCPU.dll
Class that represents a color.
public sealed class MagickColor : IMagickColor<ushort>, IEquatable<IMagickColor<ushort>?>, IComparable<IMagickColor<ushort>?>
- Inheritance
-
MagickColor
- Implements
-
IMagickColor<ushort>
- Inherited Members
Constructors
MagickColor()
Initializes a new instance of the MagickColor class.
public MagickColor()
MagickColor(IMagickColor<ushort>)
Initializes a new instance of the MagickColor class.
public MagickColor(IMagickColor<ushort> color)
Parameters
color
IMagickColor<ushort>The color to use.
MagickColor(string)
Initializes a new instance of the MagickColor class.
public MagickColor(string color)
Parameters
color
stringThe RGBA/CMYK hex string or name of the color (http://www.imagemagick.org/script/color.php). For example: #F000, #FF000000, #FFFF000000000000.
MagickColor(ushort, ushort, ushort)
Initializes a new instance of the MagickColor class.
public MagickColor(ushort red, ushort green, ushort blue)
Parameters
red
ushortRed component value of this color (0-65535).
green
ushortGreen component value of this color (0-65535).
blue
ushortBlue component value of this color (0-65535).
MagickColor(ushort, ushort, ushort, ushort)
Initializes a new instance of the MagickColor class.
public MagickColor(ushort red, ushort green, ushort blue, ushort alpha)
Parameters
red
ushortRed component value of this color (0-65535).
green
ushortGreen component value of this color (0-65535).
blue
ushortBlue component value of this color (0-65535).
alpha
ushortAlpha component value of this color (0-65535).
MagickColor(ushort, ushort, ushort, ushort, ushort)
Initializes a new instance of the MagickColor class.
public MagickColor(ushort cyan, ushort magenta, ushort yellow, ushort black, ushort alpha)
Parameters
cyan
ushortCyan component value of this color (0-65535).
magenta
ushortMagenta component value of this color (0-65535).
yellow
ushortYellow component value of this color (0-65535).
black
ushortBlack component value of this color (0-65535).
alpha
ushortAlpha component value of this color (0-65535).
Properties
A
Gets or sets the alpha component value of this color.
public ushort A { get; set; }
Property Value
B
Gets or sets the blue component value of this color.
public ushort B { get; set; }
Property Value
G
Gets or sets the green component value of this color.
public ushort G { get; set; }
Property Value
IsCmyk
Gets a value indicating whether the color is a CMYK color.
public bool IsCmyk { get; }
Property Value
K
Gets or sets the key (black) component value of this color.
public ushort K { get; set; }
Property Value
R
Gets or sets the red component value of this color.
public ushort R { get; set; }
Property Value
Methods
CompareTo(IMagickColor<ushort>?)
Compares the current instance with another object of the same type.
public int CompareTo(IMagickColor<ushort>? other)
Parameters
other
IMagickColor<ushort>The color to compare this color with.
Returns
- int
A signed number indicating the relative values of this instance and value.
Equals(IMagickColor<ushort>?)
Determines whether the specified color is equal to the current color.
public bool Equals(IMagickColor<ushort>? other)
Parameters
other
IMagickColor<ushort>The color to compare this color with.
Returns
- bool
True when the specified color is equal to the current color.
Equals(object?)
Determines whether the specified object is equal to the current color.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare this color with.
Returns
- bool
True when the specified object is equal to the current color.
FromRgb(byte, byte, byte)
Creates a new MagickColor instance from the specified 8-bit color values (red, green, and blue). The alpha value is implicitly 255 (fully opaque).
public static MagickColor FromRgb(byte red, byte green, byte blue)
Parameters
red
byteRed component value of this color.
green
byteGreen component value of this color.
blue
byteBlue component value of this color.
Returns
- MagickColor
A MagickColor instance.
FromRgba(byte, byte, byte, byte)
Creates a new MagickColor instance from the specified 8-bit color values (red, green, blue and alpha).
public static MagickColor FromRgba(byte red, byte green, byte blue, byte alpha)
Parameters
red
byteRed component value of this color.
green
byteGreen component value of this color.
blue
byteBlue component value of this color.
alpha
byteAlpha component value of this color.
Returns
- MagickColor
A MagickColor instance.
FuzzyEquals(IMagickColor<ushort>, Percentage)
Determines whether the specified color is fuzzy equal to the current color.
public bool FuzzyEquals(IMagickColor<ushort> other, Percentage fuzz)
Parameters
other
IMagickColor<ushort>The color to compare this color with.
fuzz
PercentageThe fuzz factor.
Returns
- bool
True when the specified color is fuzzy equal to the current instance.
GetHashCode()
Serves as a hash of this type.
public override int GetHashCode()
Returns
- int
A hash code for the current instance.
SetFromBytes(byte, byte, byte, byte)
Initializes the color with the specified bytes.
public void SetFromBytes(byte red, byte green, byte blue, byte alpha)
Parameters
red
byteRed component value of this color.
green
byteGreen component value of this color.
blue
byteBlue component value of this color.
alpha
byteAlpha component value of this color.
ToByteArray()
Converts the value of this instance to a byte array (RGBA or CMYKA).
public byte[] ToByteArray()
Returns
ToHexString()
Converts the value of this instance to a hexadecimal string that will not include the alpha channel if it is opaque.
public string ToHexString()
Returns
ToShortString()
Converts the value of this instance to a string representation that will not include the alpha channel if it is opaque.
public string ToShortString()
Returns
ToString()
Converts the value of this instance to a string representation.
public override string ToString()
Returns
Operators
operator ==(MagickColor?, MagickColor?)
Determines whether the specified MagickColor instances are considered equal.
public static bool operator ==(MagickColor? left, MagickColor? right)
Parameters
left
MagickColorThe first MagickColor to compare.
right
MagickColorThe second MagickColor to compare.
Returns
operator >(MagickColor?, MagickColor?)
Determines whether the first MagickColor is more than the second MagickColor.
public static bool operator >(MagickColor? left, MagickColor? right)
Parameters
left
MagickColorThe first MagickColor to compare.
right
MagickColorThe second MagickColor to compare.
Returns
operator >=(MagickColor?, MagickColor?)
Determines whether the first MagickColor is more than or equal to the second MagickColor.
public static bool operator >=(MagickColor? left, MagickColor? right)
Parameters
left
MagickColorThe first MagickColor to compare.
right
MagickColorThe second MagickColor to compare.
Returns
operator !=(MagickColor?, MagickColor?)
Determines whether the specified MagickColor instances are not considered equal.
public static bool operator !=(MagickColor? left, MagickColor? right)
Parameters
left
MagickColorThe first MagickColor to compare.
right
MagickColorThe second MagickColor to compare.
Returns
operator <(MagickColor?, MagickColor?)
Determines whether the first MagickColor is less than the second MagickColor.
public static bool operator <(MagickColor? left, MagickColor? right)
Parameters
left
MagickColorThe first MagickColor to compare.
right
MagickColorThe second MagickColor to compare.
Returns
operator <=(MagickColor?, MagickColor?)
Determines whether the first MagickColor is less than or equal to the second MagickColor.
public static bool operator <=(MagickColor? left, MagickColor? right)
Parameters
left
MagickColorThe first MagickColor to compare.
right
MagickColorThe second MagickColor to compare.
Returns
operator *(MagickColor?, Percentage?)
Multiplies the value of all non alpha channels in this MagickColor with the specified ImageMagick.Percentage.
public static MagickColor? operator *(MagickColor? color, Percentage? percentage)
Parameters
color
MagickColorThe MagickColor to multiply.
percentage
PercentageThe ImageMagick.Percentage that should be used.
Returns
- MagickColor
The MagickColor multiplied with the percentage.