Cmyk Struct

A device CMYK color: the amounts of cyan, magenta, yellow and black inks, without color profile.

public readonly struct Cmyk : IEquatable<Cmyk>

Remarks

The conversions are the naive ones of CSS Color 5 (device-cmyk()), on the encoded RGB values as they are: the black is what the three inks share (full gray component replacement), and the inks do not interact. They do not describe what a press prints: an image of CMYK samples is converted with its ICC profile (CmykConversionOptions), and colors with IccColorTransform.

The values are not validated: the conversion to RGB clips each component to [0, 1].

Implements

Constructors

NameDescription
Cmyk(double, double, double, double)Initializes a new instance of the Cmyk struct.

Cmyk(double, double, double, double)

Cmyk.cs

Initializes a new instance of the Cmyk struct.

public Cmyk(double c, double m, double y, double k)

Parameters

c double
The cyan ink, from 0 to 1.
m double
The magenta ink, from 0 to 1.
y double
The yellow ink, from 0 to 1.
k double
The black ink, from 0 to 1.

Properties

NameDescription
CGets the cyan ink, from 0 to 1.
KGets the black ink, from 0 to 1.
MGets the magenta ink, from 0 to 1.
YGets the yellow ink, from 0 to 1.

Gets the cyan ink, from 0 to 1.

public double C { get; }

Property value

double

Gets the black ink, from 0 to 1.

public double K { get; }

Property value

double

Gets the magenta ink, from 0 to 1.

public double M { get; }

Property value

double

Gets the yellow ink, from 0 to 1.

public double Y { get; }

Property value

double

Methods

NameDescription
Equals(Cmyk)Indicates whether the current object is equal to another object of the same type.
Equals(object?)Indicates whether this instance and a specified object are equal.
FromRgb(Rgba32)Converts an 8-bit RGB color to device CMYK. Alpha is ignored.
FromRgb(Rgba64)Converts a 16-bit RGB color to device CMYK. Alpha is ignored.
GetHashCode()Returns the hash code for this instance.
ToRgba32()Converts this color to an opaque 8-bit RGB color, each component clipped to [0, 1].
ToRgba64()Converts this color to an opaque 16-bit RGB color, each component clipped to [0, 1].
ToString()Returns the fully qualified type name of this instance.

Equals overloads

Equals(Cmyk)

Cmyk.cs

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Cmyk other)
Parameters
other Cmyk
An object to compare with this object.
Returns

bool true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Cmyk.cs

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)
Parameters
obj object?
The object to compare with the current instance.
Returns

bool true if obj and this instance are the same type and represent the same value; otherwise, false.

FromRgb overloads

FromRgb(Rgba32)

Cmyk.cs

Converts an 8-bit RGB color to device CMYK. Alpha is ignored.

public static Cmyk FromRgb(Rgba32 color)
Parameters
color Rgba32
The color.
Returns

Cmyk The color.

FromRgb(Rgba64)

Cmyk.cs

Converts a 16-bit RGB color to device CMYK. Alpha is ignored.

public static Cmyk FromRgb(Rgba64 color)
Parameters
color Rgba64
The color.
Returns

Cmyk The color.

GetHashCode()

Cmyk.cs

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int A 32-bit signed integer that is the hash code for this instance.

ToRgba32()

Cmyk.cs

Converts this color to an opaque 8-bit RGB color, each component clipped to [0, 1].

public Rgba32 ToRgba32()

Returns

Rgba32 The color.

ToRgba64()

Cmyk.cs

Converts this color to an opaque 16-bit RGB color, each component clipped to [0, 1].

public Rgba64 ToRgba64()

Returns

Rgba64 The color.

ToString()

Cmyk.cs

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string The fully qualified type name.

Operators

NameDescription
operator ==(Cmyk, Cmyk)Compares two colors for equality, component by component.
operator !=(Cmyk, Cmyk)Compares two colors for inequality, component by component.

operator ==(Cmyk, Cmyk)

Cmyk.cs

Compares two colors for equality, component by component.

public static bool operator ==(Cmyk left, Cmyk right)

Parameters

left Cmyk
The first color.
right Cmyk
The second color.

Returns

bool true if all the components are equal; otherwise false.

operator !=(Cmyk, Cmyk)

Cmyk.cs

Compares two colors for inequality, component by component.

public static bool operator !=(Cmyk left, Cmyk right)

Parameters

left Cmyk
The first color.
right Cmyk
The second color.

Returns

bool true if a component differs; otherwise false.