CartoType C++ API 8.8-7-gb35e4dc71
for Windows, Linux, Qt and other platforms supporting C++ development
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
CartoTypeCore::Color Class Reference

#include <cartotype_color.h>

Public Member Functions

 Color ()
 
 Color (uint32_t aValue)
 
 Color (int32_t aRed, int32_t aGreen, int32_t aBlue, int32_t aAlpha=0xFF)
 
 Color (const MString &aColor)
 
 Color (const String &aColor)
 
bool operator== (const Color &aColor) const
 
bool operator!= (const Color &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 (Color aOtherColor, int32_t aOtherColorAlpha)
 
void Blend (Color 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 Value { 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

◆ Color() [1/5]

CartoTypeCore::Color::Color ( )
inline

Creates a color and set it to opaque black.

◆ Color() [2/5]

CartoTypeCore::Color::Color ( uint32_t  aValue)
inline

Creates a color from an integer value.

◆ Color() [3/5]

CartoTypeCore::Color::Color ( int32_t  aRed,
int32_t  aGreen,
int32_t  aBlue,
int32_t  aAlpha = 0xFF 
)
inline

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

◆ Color() [4/5]

CartoTypeCore::Color::Color ( const MString aColor)
explicit

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

◆ Color() [5/5]

CartoTypeCore::Color::Color ( const String aColor)
explicit

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

Member Function Documentation

◆ Alpha()

int32_t CartoTypeCore::Color::Alpha ( ) const
inline

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

◆ Blend() [1/2]

void CartoTypeCore::Color::Blend ( Color  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 CartoTypeCore::Color::Blend ( Color  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 CartoTypeCore::Color::Blue ( ) const
inline

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

◆ CombineAlpha()

void CartoTypeCore::Color::CombineAlpha ( int32_t  aAlpha)

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

◆ Gray()

int32_t CartoTypeCore::Color::Gray ( ) const
inline

A synonym for Grey()

◆ Green()

int32_t CartoTypeCore::Color::Green ( ) const
inline

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

◆ Grey() [1/2]

int32_t CartoTypeCore::Color::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 CartoTypeCore::Color::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 CartoTypeCore::Color::IsNull ( ) const
inline

Returns true if the colour is null.

◆ operator!=()

bool CartoTypeCore::Color::operator!= ( const Color aColor) const
inline

The inequality operator.

◆ operator==()

bool CartoTypeCore::Color::operator== ( const Color aColor) const
inline

The equality operator.

◆ PremultiplyAlpha()

void CartoTypeCore::Color::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 CartoTypeCore in 32bpp RGBA bitmaps, and as the return value of MPaintServer::Color.

◆ Red()

int32_t CartoTypeCore::Color::Red ( ) const
inline

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

◆ Set()

size_t CartoTypeCore::Color::Set ( const MString aColor)

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

◆ SetAlpha()

void CartoTypeCore::Color::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

◆ Value

uint32_t CartoTypeCore::Color::Value { 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: