Table of Contents

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>
IEquatable<IMagickColor<ushort>>
IComparable<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 string

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

red ushort

Red component value of this color (0-65535).

green ushort

Green component value of this color (0-65535).

blue ushort

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

red ushort

Red component value of this color (0-65535).

green ushort

Green component value of this color (0-65535).

blue ushort

Blue component value of this color (0-65535).

alpha ushort

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

cyan ushort

Cyan component value of this color (0-65535).

magenta ushort

Magenta component value of this color (0-65535).

yellow ushort

Yellow component value of this color (0-65535).

black ushort

Black component value of this color (0-65535).

alpha ushort

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

ushort

B

Gets or sets the blue component value of this color.

public ushort B { get; set; }

Property Value

ushort

G

Gets or sets the green component value of this color.

public ushort G { get; set; }

Property Value

ushort

IsCmyk

Gets a value indicating whether the color is a CMYK color.

public bool IsCmyk { get; }

Property Value

bool

K

Gets or sets the key (black) component value of this color.

public ushort K { get; set; }

Property Value

ushort

R

Gets or sets the red component value of this color.

public ushort R { get; set; }

Property Value

ushort

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 object

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

red byte

Red component value of this color.

green byte

Green component value of this color.

blue byte

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

red byte

Red component value of this color.

green byte

Green component value of this color.

blue byte

Blue component value of this color.

alpha byte

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

other IMagickColor<ushort>

The color to compare this color with.

fuzz Percentage

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

red byte

Red component value of this color.

green byte

Green component value of this color.

blue byte

Blue component value of this color.

alpha byte

Alpha component value of this color.

ToByteArray()

Converts the value of this instance to a byte array (RGBA or CMYKA).

public byte[] ToByteArray()

Returns

byte[]

The byte array.

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

string

The string.

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

string

The string.

ToString()

Converts the value of this instance to a string representation.

public override string ToString()

Returns

string

The string.

Operators

operator ==(MagickColor?, MagickColor?)

Determines whether the specified MagickColor instances are considered equal.

public static bool operator ==(MagickColor? left, MagickColor? right)

Parameters

left MagickColor

The first MagickColor to compare.

right MagickColor

The second MagickColor to compare.

Returns

bool

operator >(MagickColor?, MagickColor?)

Determines whether the first MagickColor is more than the second MagickColor.

public static bool operator >(MagickColor? left, MagickColor? right)

Parameters

left MagickColor

The first MagickColor to compare.

right MagickColor

The second MagickColor to compare.

Returns

bool

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 MagickColor

The first MagickColor to compare.

right MagickColor

The second MagickColor to compare.

Returns

bool

operator !=(MagickColor?, MagickColor?)

Determines whether the specified MagickColor instances are not considered equal.

public static bool operator !=(MagickColor? left, MagickColor? right)

Parameters

left MagickColor

The first MagickColor to compare.

right MagickColor

The second MagickColor to compare.

Returns

bool

operator <(MagickColor?, MagickColor?)

Determines whether the first MagickColor is less than the second MagickColor.

public static bool operator <(MagickColor? left, MagickColor? right)

Parameters

left MagickColor

The first MagickColor to compare.

right MagickColor

The second MagickColor to compare.

Returns

bool

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 MagickColor

The first MagickColor to compare.

right MagickColor

The second MagickColor to compare.

Returns

bool

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 MagickColor

The MagickColor to multiply.

percentage Percentage

The ImageMagick.Percentage that should be used.

Returns

MagickColor

The MagickColor multiplied with the percentage.