ACF $AcfVersion:0$
Public Types | Public Member Functions | List of all members
icmm::CCmyk Class Reference

Primitive for representation of CMYK (Cyan, Magenta, Yellow, Black) color values. More...

#include <CCmyk.h>

Inheritance diagram for icmm::CCmyk:
icmm::TComposedColor< 4 > imath::TVector< Size, Element > iser::ISerializable istd::IChangeable istd::IPolymorphic

Public Types

enum  ComponentIndex {
  CI_CYAN , CI_MAGENTA , CI_YELLOW , CI_BLACK ,
  CI_LAST = CI_BLACK
}
 
typedef TComposedColor< 4 > BaseClass
 
- Public Types inherited from icmm::TComposedColor< 4 >
typedef imath::TVector< Size > BaseClass
 
typedef BaseClass::Elements Elements
 
- Public Types inherited from imath::TVector< Size, Element >
typedef Element ElementType
 
typedef Element Elements[Size]
 
- Public Types inherited from istd::IChangeable
enum  ChangeFlags {
  CF_ACF_INTERNAL = 0 , CF_ALL_DATA , CF_ANY , CF_DESTROYING ,
  CF_DELEGATED , CF_NO_UNDO
}
 Data model change notification flags. More...
 
enum  SupportedOperations {
  SO_NONE = 0 , SO_OBSERVE = 1 << 0 , SO_COPY = 1 << 1 , SO_CLONE = 1 << 2 ,
  SO_COMPARE = 1 << 3 , SO_RESET = 1 << 4
}
 Flags for supported operations. More...
 
enum  CompatibilityMode { CM_STRICT , CM_WITHOUT_REFS , CM_WITH_REFS , CM_CONVERT }
 Control how relationship betweeen objects are interpreted. More...
 
typedef QMultiMap< QByteArray, QVariant > ChangeInfoMap
 

Public Member Functions

 CCmyk (double c=0.0, double m=0.0, double y=0.0, double k=0.0)
 
 CCmyk (const CCmyk &color)
 
double GetC () const
 
void SetC (double value)
 
double GetM () const
 
void SetM (double value)
 
double GetY () const
 
void SetY (double value)
 
double GetK () const
 
void SetK (double value)
 
virtual bool Serialize (iser::IArchive &archive) override
 Load or store state of this object as a archive stream.
 
CCmyk operator+ (const CCmyk &color) const
 
CCmyk operator- (const CCmyk &color) const
 
CCmyk operator* (const CCmyk &color) const
 
CCmyk operator/ (const CCmyk &color) const
 
CCmyk operator* (double value) const
 
CCmyk operator/ (double value) const
 
CCmykoperator= (const CCmyk &color)
 
const CCmykoperator+= (const CCmyk &color)
 
const CCmykoperator-= (const CCmyk &color)
 
const CCmykoperator*= (const CCmyk &color)
 
const CCmykoperator/= (const CCmyk &color)
 
const CCmykoperator*= (double value)
 
const CCmykoperator/= (double value)
 
- Public Member Functions inherited from icmm::TComposedColor< 4 >
 TComposedColor ()
 
 TComposedColor (const BaseClass &value)
 
 TComposedColor (const imath::CVarVector &vector)
 
 TComposedColor (const TComposedColor< Size > &color)=default
 
void GetRounded (const imath::IDoubleManip &manipulator, TComposedColor< Size > &result)
 Get color after components value rounding with specified precision.
 
bool IsRoundedEqual (const TComposedColor< Size > &color, const imath::IDoubleManip &manipulator) const
 Check if two values are equal after rounding.
 
bool IsSimilar (const TComposedColor< Size > &color, double tolerance=I_BIG_EPSILON) const
 Allows to compare two colors with tolerance.
 
bool IsNormalized () const
 Check if this color value is normalized.
 
void Normalize ()
 Make this color to be normalized.
 
void GetNormalized (TComposedColor< Size > &result) const
 Get normalized color.
 
TComposedColor< Size > operator+ (const TComposedColor< Size > &color) const
 
TComposedColor< Size > operator- (const TComposedColor< Size > &color) const
 
TComposedColor< Size > operator* (const TComposedColor< Size > &color) const
 
TComposedColor< Size > operator* (double value) const
 
TComposedColor< Size > operator/ (const TComposedColor< Size > &color) const
 
TComposedColor< Size > operator/ (double value) const
 
const TComposedColor< Size > & operator= (const TComposedColor< Size > &color)
 
const TComposedColor< Size > & operator= (double colorValue)
 
const TComposedColor< Size > & operator+= (const TComposedColor< Size > &color)
 
const TComposedColor< Size > & operator-= (const TComposedColor< Size > &color)
 
const TComposedColor< Size > & operator*= (const TComposedColor< Size > &color)
 
const TComposedColor< Size > & operator*= (double value)
 
const TComposedColor< Size > & operator/= (const TComposedColor< Size > &color)
 
const TComposedColor< Size > & operator/= (double value)
 
- Public Member Functions inherited from imath::TVector< Size, Element >
 TVector ()
 Creates an uninitialized vector.
 
 TVector (const TVector< Size, Element > &vector)
 Creates a copy of another vector.
 
 TVector (std::initializer_list< Element > values)
 Creates a vector from an initializer list.
 
const Element & GetElement (int i) const
 Gets the element at the specified index (read-only).
 
Element & GetElementRef (int i)
 Gets a reference to the element at the specified index (read-write).
 
void SetElement (int i, const Element &value)
 Sets the element at the specified index.
 
void SetAllElements (const Element &value)
 Sets all elements to the same value.
 
void Reset ()
 Sets all coordinates to zero.
 
void Clear ()
 Sets all coordinates to zero.
 
const TVector< Size, Element >::ElementsGetElements () const
 Get read-only access to internal element container.
 
TVector< Size, Element >::ElementsGetElementsRef ()
 Get access to internal element container.
 
void Translate (const TVector< Size, Element > &vector)
 Translates (adds) another vector to this vector.
 
TVector< Size, Element > GetTranslated (const TVector< Size, Element > &vector)
 Returns a new vector that is the translation of this vector.
 
void GetTranslated (const TVector< Size, Element > &vector, TVector< Size, Element > &result)
 Computes the translated vector and stores it in the result parameter.
 
void ScaledCumulate (const TVector< Size, Element > &vector, Element scale)
 Adds a scaled vector to this vector.
 
bool IsNull (Element tolerance=I_BIG_EPSILON) const
 Checks if this vector is null (all elements approximately zero).
 
Element GetDotProduct (const TVector< Size, Element > &vector) const
 Calculates the dot product with another vector.
 
Element GetLength2 () const
 Calculates the squared Euclidean length of the vector.
 
Element GetLength () const
 Calculates the Euclidean length (magnitude) of the vector.
 
Element GetDistance2 (const TVector< Size, Element > &vector) const
 Calculates the squared distance to another vector.
 
Element GetDistance (const TVector< Size, Element > &vector) const
 Calculates the Euclidean distance to another vector.
 
Element GetElementsSum () const
 Calculates the sum of all vector elements.
 
bool Normalize (Element length=1.0)
 Normalizes the vector to a specified length.
 
bool GetNormalized (TVector< Size, Element > &result, Element length=1.0) const
 Returns a normalized copy of this vector with specified length.
 
void GetMinimal (const TVector< Size, Element > &vector, TVector< Size, Element > &result) const
 Get vector with minimal elements values.
 
void GetMaximal (const TVector< Size, Element > &vector, TVector< Size, Element > &result) const
 Get vector with maximal elements values.
 
bool Serialize (iser::IArchive &archive)
 Serialize this vector to specified archive.
 
bool operator== (const TVector< Size, Element > &vector) const
 
bool operator!= (const TVector< Size, Element > &vector) const
 
bool operator< (const TVector< Size, Element > &vector) const
 
bool operator> (const TVector< Size, Element > &vector) const
 
bool operator<= (const TVector< Size, Element > &vector) const
 
bool operator>= (const TVector< Size, Element > &vector) const
 
TVector< Size, Element > & operator= (const TVector< Size, Element > &vector)=default
 
TVector< Size, Element > operator- () const
 
TVector< Size, Element > operator+ (const TVector< Size, Element > &vector) const
 
TVector< Size, Element > operator- (const TVector< Size, Element > &vector) const
 
TVector< Size, Element > operator* (Element scalar) const
 
TVector< Size, Element > operator/ (Element scalar) const
 
TVector< Size, Element > & operator+= (const TVector< Size, Element > &vector)
 
TVector< Size, Element > & operator-= (const TVector< Size, Element > &vector)
 
TVector< Size, Element > & operator*= (Element scalar)
 
TVector< Size, Element > & operator/= (Element scalar)
 
const Element & operator[] (int i) const
 
Element & operator[] (int i)
 
- Public Member Functions inherited from iser::ISerializable
virtual quint32 GetMinimalVersion (int versionId) const
 Get minimal needed version to correct storing of this data.
 
- Public Member Functions inherited from istd::IChangeable
virtual int GetSupportedOperations () const
 Get set of flags for supported operations.
 
virtual bool CopyFrom (const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
 Copy this object from another one.
 
virtual bool IsEqual (const IChangeable &object) const
 Compare this object with another object.
 
virtual istd::TUniqueInterfacePtr< istd::IChangeableCloneMe (CompatibilityMode mode=CM_WITHOUT_REFS) const
 Make a copy of this object.
 
virtual bool ResetData (CompatibilityMode mode=CM_WITHOUT_REFS)
 Reset data to its default state.
 
virtual void BeginChanges (const ChangeSet &changeSet)
 Starts the change transaction.
 
virtual void EndChanges (const ChangeSet &changeSet)
 Ends the change transaction.
 
virtual void BeginChangeGroup (const ChangeSet &changeSet)
 Starts group of changes.
 
virtual void EndChangeGroup (const ChangeSet &changeSet)
 Ends group of changes.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Additional Inherited Members

- Static Public Member Functions inherited from imath::TVector< Size, Element >
static int GetElementsCount ()
 Get number of elements.
 
static bool SetElementsCount (int count)
 Set number of elements.
 
static const TVector< Size, Element > & GetZero ()
 Get vector with all coordinates set to 0.
 
- Static Public Member Functions inherited from istd::IChangeable
static const ChangeSetGetNoChanges ()
 Get empty set of changes.
 
static const ChangeSetGetAnyChange ()
 Get anonymous change set.
 
static const ChangeSetGetAllChanges ()
 Get anonymous change set.
 
static const ChangeSetGetDelegatedChanges ()
 Get delegated change set.
 
- Protected Member Functions inherited from istd::IChangeable
virtual void OnBeginChanges ()
 Callback function for begin change event.
 
virtual void OnEndChanges (const ChangeSet &changeSet)
 Callback function for end change event.
 
- Protected Attributes inherited from imath::TVector< Size, Element >
Elements m_elements
 

Detailed Description

Primitive for representation of CMYK (Cyan, Magenta, Yellow, Black) color values.

Purpose

CCmyk represents colors in the CMYK subtractive color model, which is the standard for color printing and physical media. Unlike RGB (additive), CMYK works by subtracting colors from white light, as inks absorb certain wavelengths. The K (Key/Black) component is added for practical printing reasons - combining CMY inks doesn't produce true black and uses excessive ink.

CMYK Color Model

CMYK is a subtractive color model where colors are created by absorbing light:

Usage Examples

// Example 1: Creating CMYK colors
icmm::CCmyk white(0.0, 0.0, 0.0, 0.0); // No ink
icmm::CCmyk black(0.0, 0.0, 0.0, 1.0); // Full black ink
icmm::CCmyk cyan(1.0, 0.0, 0.0, 0.0); // Pure cyan
icmm::CCmyk magenta(0.0, 1.0, 0.0, 0.0); // Pure magenta
icmm::CCmyk yellow(0.0, 0.0, 1.0, 0.0); // Pure yellow
// Mixed colors
icmm::CCmyk blue(1.0, 1.0, 0.0, 0.0); // Cyan + Magenta
icmm::CCmyk green(1.0, 0.0, 1.0, 0.0); // Cyan + Yellow
icmm::CCmyk red(0.0, 1.0, 1.0, 0.0); // Magenta + Yellow
// Example 2: Component access
color.SetC(0.2); // 20% cyan
color.SetM(0.5); // 50% magenta
color.SetY(0.8); // 80% yellow
color.SetK(0.1); // 10% black
double cyan = color.GetC();
double magenta = color.GetM();
double yellow = color.GetY();
double black = color.GetK();
// Example 3: RGB to CMYK conversion (naive approach)
icmm::CCmyk RgbToCmykNaive(const icmm::CRgb& rgb)
{
// Simple CMY conversion
double c = 1.0 - rgb.GetRed();
double m = 1.0 - rgb.GetGreen();
double y = 1.0 - rgb.GetBlue();
// Extract black component (UCR - Under Color Removal)
double k = qMin(c, qMin(m, y));
// Reduce CMY by black amount
if (k < 1.0) {
c = (c - k) / (1.0 - k);
m = (m - k) / (1.0 - k);
y = (y - k) / (1.0 - k);
} else {
c = m = y = 0.0;
}
return icmm::CCmyk(c, m, y, k);
}
// Example 4: Estimating ink coverage
double GetInkCoverage(const icmm::CCmyk& color)
{
// Total ink as percentage (400% max for CMYK)
return (color.GetC() + color.GetM() +
color.GetY() + color.GetK()) * 100.0;
}
icmm::CCmyk richBlack(0.6, 0.4, 0.4, 1.0); // Rich black
double coverage = GetInkCoverage(richBlack); // 240%
// Example 5: Checking ink limits
bool IsWithinInkLimit(const icmm::CCmyk& color, double maxCoverage = 3.0)
{
double total = color.GetC() + color.GetM() +
color.GetY() + color.GetK();
return total <= maxCoverage;
}
// Example 6: Creating rich black
icmm::CCmyk CreateRichBlack(double blackAmount = 1.0,
double cmy = 0.4)
{
// Rich black uses CMY + K for deeper black
return icmm::CCmyk(cmy, cmy, cmy, blackAmount);
}
icmm::CCmyk standardBlack = CreateRichBlack(1.0, 0.0); // Pure K
icmm::CCmyk richBlack = CreateRichBlack(1.0, 0.4); // K + CMY
// Example 7: Gray component replacement (GCR)
icmm::CCmyk ApplyGCR(const icmm::CCmyk& color, double gcrAmount)
{
// Find minimum CMY value
double minCMY = qMin(color.GetC(), qMin(color.GetM(), color.GetY()));
// Replace with black
double addBlack = minCMY * gcrAmount;
return icmm::CCmyk(
color.GetC() - addBlack,
color.GetM() - addBlack,
color.GetY() - addBlack,
color.GetK() + addBlack
);
}
// Example 8: Spot color separation
struct SpotColorData {
QString name;
icmm::CCmyk processEquivalent;
double angle; // Screen angle for printing
};
SpotColorData CreateSpotColor(const QString& name,
const icmm::CCmyk& cmyk)
{
SpotColorData spot;
spot.name = name;
spot.processEquivalent = cmyk;
spot.angle = 45.0; // Default angle
return spot;
}
Primitive for representation of CMYK (Cyan, Magenta, Yellow, Black) color values.
Definition CCmyk.h:191
double GetK() const
Definition CCmyk.h:295
void SetC(double value)
Definition CCmyk.h:265
double GetY() const
Definition CCmyk.h:283
double GetM() const
Definition CCmyk.h:271
double GetC() const
Definition CCmyk.h:259
void SetK(double value)
Definition CCmyk.h:301
void SetM(double value)
Definition CCmyk.h:277
void SetY(double value)
Definition CCmyk.h:289
Primitive for representation of RGB color values.
Definition CRgb.h:168
double GetBlue() const
Definition CRgb.h:256
double GetGreen() const
Definition CRgb.h:244
double GetRed() const
Definition CRgb.h:232

CMYK and Printing

Ink Coverage:**

Best Practices

Limitations

Note
Component values range from 0.0 (no ink) to 1.0 (full ink coverage)
See also
icmm::TComposedColor, icmm::CCmykColorModel, icmm::CRgb, icmm::CRgbToCmykTransformation, icmm::CCmykToRgbTransformation

Definition at line 190 of file CCmyk.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 193 of file CCmyk.h.

Member Enumeration Documentation

◆ ComponentIndex

Enumerator
CI_CYAN 
CI_MAGENTA 
CI_YELLOW 
CI_BLACK 
CI_LAST 

Definition at line 195 of file CCmyk.h.

Constructor & Destructor Documentation

◆ CCmyk() [1/2]

icmm::CCmyk::CCmyk ( double  c = 0.0,
double  m = 0.0,
double  y = 0.0,
double  k = 0.0 
)
inline

◆ CCmyk() [2/2]

icmm::CCmyk::CCmyk ( const CCmyk color)
inline

Definition at line 251 of file CCmyk.h.

Member Function Documentation

◆ GetC()

double icmm::CCmyk::GetC ( ) const
inline

Definition at line 259 of file CCmyk.h.

References CI_CYAN, and imath::TVector< Size, Element >::GetElement().

◆ GetK()

double icmm::CCmyk::GetK ( ) const
inline

Definition at line 295 of file CCmyk.h.

References CI_BLACK, and imath::TVector< Size, Element >::GetElement().

◆ GetM()

double icmm::CCmyk::GetM ( ) const
inline

Definition at line 271 of file CCmyk.h.

References CI_MAGENTA, and imath::TVector< Size, Element >::GetElement().

◆ GetY()

double icmm::CCmyk::GetY ( ) const
inline

Definition at line 283 of file CCmyk.h.

References CI_YELLOW, and imath::TVector< Size, Element >::GetElement().

◆ operator*() [1/2]

CCmyk icmm::CCmyk::operator* ( const CCmyk color) const
inline

Definition at line 329 of file CCmyk.h.

◆ operator*() [2/2]

CCmyk icmm::CCmyk::operator* ( double  value) const
inline

Definition at line 349 of file CCmyk.h.

◆ operator*=() [1/2]

const CCmyk & icmm::CCmyk::operator*= ( const CCmyk color)
inline

Definition at line 393 of file CCmyk.h.

References icmm::TComposedColor< 4 >::operator*=().

◆ operator*=() [2/2]

const CCmyk & icmm::CCmyk::operator*= ( double  value)
inline

Definition at line 409 of file CCmyk.h.

References icmm::TComposedColor< 4 >::operator*=().

◆ operator+()

CCmyk icmm::CCmyk::operator+ ( const CCmyk color) const
inline

Definition at line 309 of file CCmyk.h.

◆ operator+=()

const CCmyk & icmm::CCmyk::operator+= ( const CCmyk color)
inline

Definition at line 377 of file CCmyk.h.

References icmm::TComposedColor< 4 >::operator+=().

◆ operator-()

CCmyk icmm::CCmyk::operator- ( const CCmyk color) const
inline

Definition at line 319 of file CCmyk.h.

◆ operator-=()

const CCmyk & icmm::CCmyk::operator-= ( const CCmyk color)
inline

Definition at line 385 of file CCmyk.h.

References icmm::TComposedColor< 4 >::operator-=().

◆ operator/() [1/2]

CCmyk icmm::CCmyk::operator/ ( const CCmyk color) const
inline

Definition at line 339 of file CCmyk.h.

◆ operator/() [2/2]

CCmyk icmm::CCmyk::operator/ ( double  value) const
inline

Definition at line 359 of file CCmyk.h.

◆ operator/=() [1/2]

const CCmyk & icmm::CCmyk::operator/= ( const CCmyk color)
inline

Definition at line 401 of file CCmyk.h.

References icmm::TComposedColor< 4 >::operator/=().

◆ operator/=() [2/2]

const CCmyk & icmm::CCmyk::operator/= ( double  value)
inline

Definition at line 417 of file CCmyk.h.

References icmm::TComposedColor< 4 >::operator/=().

◆ operator=()

CCmyk & icmm::CCmyk::operator= ( const CCmyk color)
inline

Definition at line 369 of file CCmyk.h.

References icmm::TComposedColor< 4 >::operator=().

◆ Serialize()

virtual bool icmm::CCmyk::Serialize ( iser::IArchive archive)
overridevirtual

Load or store state of this object as a archive stream.

Type of operation is depending on archive type.

See also
iser::IArchive

Reimplemented from icmm::TComposedColor< 4 >.

◆ SetC()

void icmm::CCmyk::SetC ( double  value)
inline

Definition at line 265 of file CCmyk.h.

References CI_CYAN, and imath::TVector< Size, Element >::SetElement().

◆ SetK()

void icmm::CCmyk::SetK ( double  value)
inline

Definition at line 301 of file CCmyk.h.

References CI_BLACK, and imath::TVector< Size, Element >::SetElement().

◆ SetM()

void icmm::CCmyk::SetM ( double  value)
inline

Definition at line 277 of file CCmyk.h.

References CI_MAGENTA, and imath::TVector< Size, Element >::SetElement().

◆ SetY()

void icmm::CCmyk::SetY ( double  value)
inline

Definition at line 289 of file CCmyk.h.

References CI_YELLOW, and imath::TVector< Size, Element >::SetElement().


The documentation for this class was generated from the following file: