CartoType C++ API 7.8.2, 2022-03-25
for Windows, Linux, Qt and other platforms supporting C++ development
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CartoType::TColor Class Reference

#include <cartotype_color.h>

Public Member Functions

 TColor ()
 
 TColor (uint32_t aValue)
 
 TColor (int32_t aRed, int32_t aGreen, int32_t aBlue, int32_t aAlpha=0xFF)
 
 TColor (const MString &aColor)
 
 TColor (const CString &aColor)
 
bool operator== (const TColor &aColor) const
 
bool operator!= (const TColor &aColor) const
 
int32_t Red () const
 
int32_t Green () const
 
int32_t Blue () const
 
int32_t Grey () const
 
int32_t Gray () const
 
int32_t Alpha () const
 
bool IsNull () const
 
void SetAlpha (int32_t aAlpha)
 
void CombineAlpha (int32_t aAlpha)
 
void PremultiplyAlpha ()
 
void Blend (TColor aOtherColor, int32_t aOtherColorAlpha)
 
void Blend (TColor aOtherColor)
 
size_t Set (const MString &aColor)
 

Static Public Member Functions

static int32_t Grey (int32_t aRed, int32_t aGreen, int32_t aBlue)
 

Public Attributes

uint32_t iValue { KBlack }
 

Detailed Description

A color.

Colors are represented by 32-bit integers containing 8 bits each of red, green, blue and alpha channel (transparency) data.

Constructor & Destructor Documentation

◆ TColor() [1/5]

CartoType::TColor::TColor ( )
inline

Creates a color and set it to opaque black.

◆ TColor() [2/5]

CartoType::TColor::TColor ( uint32_t  aValue)
inline

Creates a color from an integer value.

◆ TColor() [3/5]

CartoType::TColor::TColor ( int32_t  aRed,
int32_t  aGreen,
int32_t  aBlue,
int32_t  aAlpha = 0xFF 
)
inline

Creates a color from red, green, blue and alpha values.

◆ TColor() [4/5]

CartoType::TColor::TColor ( const MString aColor)
explicit

Creates a color from a color expression as used in style sheets.

◆ TColor() [5/5]

CartoType::TColor::TColor ( const CString aColor)
explicit

Creates a color from a color expression as used in style sheets.

Member Function Documentation

◆ Alpha()

int32_t CartoType::TColor::Alpha ( ) const
inline

Returns the alpha (transparency) level as a value in the range 0...255: 0 = transparent, 255 = opaque.

◆ Blend() [1/2]

void CartoType::TColor::Blend ( TColor  aOtherColor)

Blends aOtherColor with this color in the proportion specified by the other color's alpha value, preserving this color's alpha value.

◆ Blend() [2/2]

void CartoType::TColor::Blend ( TColor  aOtherColor,
int32_t  aOtherColorAlpha 
)

Blends aOtherColor with this color in the proportion specified by aOtherColorAlpha, which must be in the range 0...255.

◆ Blue()

int32_t CartoType::TColor::Blue ( ) const
inline

Returns the blue component as a value in the range 0...255.

◆ CombineAlpha()

void CartoType::TColor::CombineAlpha ( int32_t  aAlpha)

Multiplies the current alpha value by a new alpha value in the range 0...255.

◆ Gray()

int32_t CartoType::TColor::Gray ( ) const
inline

A synonym for Grey()

◆ Green()

int32_t CartoType::TColor::Green ( ) const
inline

Returns the green component as a value in the range 0...255.

◆ Grey() [1/2]

int32_t CartoType::TColor::Grey ( ) const
inline

Returns the grey level as a value in the range 0...255. Uses the formula Grey = (Red * 0.299 + Green * 0.587 + Blue * 0.114), derived from the BT.601 standard.

◆ Grey() [2/2]

static int32_t CartoType::TColor::Grey ( int32_t  aRed,
int32_t  aGreen,
int32_t  aBlue 
)
inlinestatic

Returns a grey level as a value in the range 0...255, calculated from red, green and blue levels in that range. Uses the formula Grey = (Red * 0.299 + Green * 0.587 + Blue * 0.114), derived from the BT.601 standard.

◆ IsNull()

bool CartoType::TColor::IsNull ( ) const
inline

Returns true if the colour is null.

◆ operator!=()

bool CartoType::TColor::operator!= ( const TColor aColor) const
inline

The inequality operator.

◆ operator==()

bool CartoType::TColor::operator== ( const TColor aColor) const
inline

The equality operator.

◆ PremultiplyAlpha()

void CartoType::TColor::PremultiplyAlpha ( )

Converts a color to premultiplied-alpha format. This function assumes that the color is in non-premultiplied-alpha format, where the three color components can have any value, and multiplies the color components by the alpha value, yielding values in the range 0...alpha.

Premultiplied alpha format is the format used by CartoType in 32bpp RGBA bitmaps, and as the return value of MPaintServer::Color.

◆ Red()

int32_t CartoType::TColor::Red ( ) const
inline

Returns the red component as a value in the range 0...255.

◆ Set()

size_t CartoType::TColor::Set ( const MString aColor)

Sets a color from a string. Returns the number of characters successfully parsed.

◆ SetAlpha()

void CartoType::TColor::SetAlpha ( int32_t  aAlpha)
inline

Sets the alpha (transparency) level to a value in the range 0...255: 0 = transparent, 255 = opaque.

Member Data Documentation

◆ iValue

uint32_t CartoType::TColor::iValue { KBlack }

The color value, containing, starting with the least significant byte, red, green, blue and alpha levels, each stored in eight bits. The color levels represent intensity. The alpha level represents opacity.


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