Class MagickColor
- Namespace
- ImageMagick
- Assembly
- Magick.NET-Q8-AnyCPU.dll
Class that represents a color.
public sealed class MagickColor : IMagickColor<byte>, IEquatable<IMagickColor<byte>?>, IComparable<IMagickColor<byte>?>- Inheritance
- 
      
      MagickColor
- Implements
- 
      IMagickColor<byte>
- Inherited Members
Constructors
MagickColor()
Initializes a new instance of the MagickColor class.
public MagickColor()MagickColor(IMagickColor<byte>)
Initializes a new instance of the MagickColor class.
public MagickColor(IMagickColor<byte> color)Parameters
- colorIMagickColor<byte>
- The color to use. 
MagickColor(byte, byte, byte)
Initializes a new instance of the MagickColor class.
public MagickColor(byte red, byte green, byte blue)Parameters
- redbyte
- Red component value of this color (0-255). 
- greenbyte
- Green component value of this color (0-255). 
- bluebyte
- Blue component value of this color (0-255). 
MagickColor(byte, byte, byte, byte)
Initializes a new instance of the MagickColor class.
public MagickColor(byte red, byte green, byte blue, byte alpha)Parameters
- redbyte
- Red component value of this color (0-255). 
- greenbyte
- Green component value of this color (0-255). 
- bluebyte
- Blue component value of this color (0-255). 
- alphabyte
- Alpha component value of this color (0-255). 
MagickColor(byte, byte, byte, byte, byte)
Initializes a new instance of the MagickColor class.
public MagickColor(byte cyan, byte magenta, byte yellow, byte black, byte alpha)Parameters
- cyanbyte
- Cyan component value of this color (0-255). 
- magentabyte
- Magenta component value of this color (0-255). 
- yellowbyte
- Yellow component value of this color (0-255). 
- blackbyte
- Black component value of this color (0-255). 
- alphabyte
- Alpha component value of this color (0-255). 
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. 
Properties
A
Gets or sets the alpha component value of this color.
public byte A { get; set; }Property Value
B
Gets or sets the blue component value of this color.
public byte B { get; set; }Property Value
G
Gets or sets the green component value of this color.
public byte 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 byte K { get; set; }Property Value
R
Gets or sets the red component value of this color.
public byte R { get; set; }Property Value
Methods
CompareTo(IMagickColor<byte>?)
Compares the current instance with another object of the same type.
public int CompareTo(IMagickColor<byte>? other)Parameters
- otherIMagickColor<byte>
- The color to compare this color with. 
Returns
- int
- A signed number indicating the relative values of this instance and value. 
Equals(IMagickColor<byte>?)
Determines whether the specified color is equal to the current color.
public bool Equals(IMagickColor<byte>? other)Parameters
- otherIMagickColor<byte>
- 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<byte>, Percentage)
Determines whether the specified color is fuzzy equal to the current color.
public bool FuzzyEquals(IMagickColor<byte> other, Percentage fuzz)Parameters
- otherIMagickColor<byte>
- 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.