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
- colorIMagickColor<ushort>
- The color to use. 
MagickColor(string)
Initializes a new instance of the MagickColor class.
public MagickColor(string color)Parameters
- colorstring
- The 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
- redushort
- Red component value of this color (0-65535). 
- greenushort
- Green component value of this color (0-65535). 
- blueushort
- Blue 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
- redushort
- Red component value of this color (0-65535). 
- greenushort
- Green component value of this color (0-65535). 
- blueushort
- Blue component value of this color (0-65535). 
- alphaushort
- Alpha 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
- cyanushort
- Cyan component value of this color (0-65535). 
- magentaushort
- Magenta component value of this color (0-65535). 
- yellowushort
- Yellow component value of this color (0-65535). 
- blackushort
- Black component value of this color (0-65535). 
- alphaushort
- Alpha 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
- otherIMagickColor<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
- otherIMagickColor<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
- objobject
- The 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
- redbyte
- Red component value of this color. 
- greenbyte
- Green component value of this color. 
- bluebyte
- Blue 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
- redbyte
- Red component value of this color. 
- greenbyte
- Green component value of this color. 
- bluebyte
- Blue component value of this color. 
- alphabyte
- Alpha 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
- otherIMagickColor<ushort>
- The color to compare this color with. 
- fuzzPercentage
- The 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
- redbyte
- Red component value of this color. 
- greenbyte
- Green component value of this color. 
- bluebyte
- Blue component value of this color. 
- alphabyte
- Alpha 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
- leftMagickColor
- The first MagickColor to compare. 
- rightMagickColor
- The 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
- leftMagickColor
- The first MagickColor to compare. 
- rightMagickColor
- The 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
- leftMagickColor
- The first MagickColor to compare. 
- rightMagickColor
- The 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
- leftMagickColor
- The first MagickColor to compare. 
- rightMagickColor
- The 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
- leftMagickColor
- The first MagickColor to compare. 
- rightMagickColor
- The 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
- leftMagickColor
- The first MagickColor to compare. 
- rightMagickColor
- The 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
- colorMagickColor
- The MagickColor to multiply. 
- percentagePercentage
- The ImageMagick.Percentage that should be used. 
Returns
- MagickColor
- The MagickColor multiplied with the percentage.