Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



Location: gdi.h
Link against: gdi.lib

Class TRgb

TRgb

Support

Supported from 5.0

Description

24-bit RGB colour value with 8 bits each for red, green and blue.

All Graphics drawing functions are specified in terms of a 32-bit TRgb colour containing the three colour values plus 8 unused bits. For hardware which does not support 24-bit colour, a mapping from TRgb to display colours is performed.

The supported display modes are enumerated in the TDisplayMode type. In each display mode a unique index can represent each physical colours supported, and which can be mapped onto a full RGB value. The mappings are as follows:

Defined in TRgb:
Blue(), Color16(), Color16M(), Color256(), Color4K(), Color64K(), Difference(), ExternalizeL(), Gray16(), Gray2(), Gray256(), Gray4(), Green(), InternalizeL(), Red(), SetBlue(), SetGreen(), SetRed(), TRgb(), Value(), operator!=(), operator&(), operator&=(), operator==(), operator^(), operator^=(), operator|(), operator|=(), operator~()

See also:


Construction and destruction


TRgb()

TRgb();

Description

Constructs default TRgb with all 3 colour components set to 255.


TRgb()

TRgb(TUint32 aValue);

Description

Constructs a TRgb directly from a single 32-bit integer.

The integer is of the form 0x00bbggrr, where bb is the hex number of blue, gg is the hex number for green, and rr is the hex number for red. For example, TRgb(2,4,8) using the 3 colour constructor is equal to TRgb(0x00080402) using this constructor.

Parameters

TUint32 aValue

Integer representing colour value. Takes form 0x00bbggrr.


TRgb()

TRgb(TInt aRed,TInt aGreen,TInt aBlue);

Description

Constructs a TRgb from its three component colours.

Each colour has a value between 0 and 255.

Parameters

TInt aRed

Red component of the colour (0 — 255).

TInt aGreen

Green component of the colour (0 — 255).

TInt aBlue

Blue component of the colour (0 — 255).

[Top]


Setting colour components


SetRed()

void SetRed(TInt aRed);

Description

Sets the red component.

Parameters

TInt aRed

Red component (0 — 255).


SetGreen()

void SetGreen(TInt aGreen);

Description

Sets the green component.

Parameters

TInt aGreen

Green component (0 — 255).


SetBlue()

void SetBlue(TInt aBlue);

Description

Sets the blue component.

Parameters

TInt aBlue

Blue component (0 — 255).

[Top]


Get value of colour components


Blue()

TInt Blue() const;

Description

Gets the blue component.

Return value

TInt

The blue component (0 — 255).


Red()

TInt Red() const;

Description

Gets the red component.

Return value

TInt

The blue component (0 — 255).


Green()

TInt Green() const;

Description

Gets the green component.

Return value

TInt

The blue component (0 — 255).


Value()

TUint32 Value() const;

Description

Gets the 24-bit value of the TRgb as a 32-bit integer.

Return value

TUint32

The 32 bit value of the TRgb. The has the form 0x00bbggrr.

[Top]


Converting to or from grayscale/colour levels


Gray2()

static TRgb Gray2(TInt aGray2);

Description

Gets TRgb from 2 level grayscale.

The function takes a grayscale argument and return a TRgb whose red, green and blue values are set to an appropriate level.

Parameters

TInt aGray2

Grayscale value to be converted.

Return value

TRgb

Equivalent 24 bit colour. Gray2 has only 2 levels (black and white), the function returns r=g=b=0 or r=g=b=255.


Gray4()

static TRgb Gray4(TInt aGray4);

Description

Gets TRgb from 4 level grayscale.

The function takes a grayscale argument and return a TRgb whose red, green and blue values are set to an appropriate level.

Parameters

TInt aGray4

Grayscale value to be converted.

Return value

TRgb

Equivalent 24 bit colour. Gray4 has 4 levels — the function returns r=g=b=85*c, where c=0,1,2, or 3.


Gray16()

static TRgb Gray16(TInt aGray16);

Description

Gets TRgb from 16 level grayscale.

The function takes a grayscale argument and return a TRgb whose red, green and blue values are set to an appropriate level.

Parameters

TInt aGray16

Grayscale value to be converted.

Return value

TRgb

Equivalent 24 bit colour. Gray16 has 16 levels — the function returns r=g=b=17*c, where c=0, 1, ... 15.


Gray256()

static TRgb Gray256(TInt aGray256);

Description

Gets TRgb from 256 level grayscale.

The function takes a grayscale argument and return a TRgb whose red, green and blue values are set to an appropriate level.

Parameters

TInt aGray256

Grayscale value to be converted.

Return value

TRgb

Equivalent 24 bit colour. Gray256 has 256 levels — the function returns r=g=b=c, where c=0, 1, ... 255.


Color16()

static TRgb Color16(TInt aColor16);

Description

Gets TRgb from 4 bit colour index.

The function takes a 4 bit index into a colour palette and returns a TRgb whose red, green and blue values are set to an appropriate level.

Parameters

TInt aColor16

4 bit index into a colour palette

Return value

TRgb

Equivalent 24 bit colour.


Color256()

static TRgb Color256(TInt aColor256);

Description

Gets TRgb from 8 bit colour index.

The function takes an 8 bit index into a colour palette and returns a TRgb whose red, green and blue values are set to an appropriate level.

Parameters

TInt aColor256

8 bit index into a colour palette.

Return value

TRgb

Equivalent 24 bit colour.


Color4K()

static TRgb Color4K(TInt aColor4K);

Description

Gets TRgb from 4K colour index.

The function takes a 12 bit index into a colour palette and returns a TRgb whose red, green and blue values are set to an appropriate level.

Parameters

TInt aColor4K

12 bit index into a colour palette

Return value

TRgb

Equivalent 24 bit colour.


Color64K()

static TRgb Color64K(TInt aColor64K);

Description

Gets TRgb from 64K colour index.

The function takes a 16 bit index into a colour palette and returns a TRgb whose red, green and blue values are set to an appropriate level.

Parameters

TInt aColor64K

16 bit index into a colour palette

Return value

TRgb

Equivalent 24 bit colour.


Color16M()

static TRgb Color16M(TInt aColor16M);

Description

Gets TRgb from 16M colour index.

The function takes a 24 bit index into a colour palette and returns the TRgb whose red, green and blue values represent it exactly.

Parameters

TInt aColor16M

24 bit index into a colour palette

Return value

TRgb

The TRgb which represents the index exactly.


Gray2()

TInt Gray2() const;

Description

Gets a 2 level grayscale value from this TRgb.

Return value

TInt

Equivalent 2 level grayscale value. The greyscale value is 0 or 1, and is calculated using c=(2*r+5*g+b)/1024. Note that the return value is rounded down to the nearest integer.


Gray4()

TInt Gray4() const;

Description

Gets a 4 level grayscale value from this TRgb.

Return value

TInt

Equivalent 4 level grayscale value. The greyscale value is calculated using c=(2*r+5*g+b)/512. Note that the return value is rounded down to the nearest integer.


Gray16()

TInt Gray16() const;

Description

Gets a 16 level grayscale value from this TRgb.

Return value

TInt

The greyscale value is calculated using c=(2*r+5*g+b)/128. Note that the return value is rounded down to the nearest integer.


Gray256()

TInt Gray256() const;

Description

Gets a 256 level grayscale value from this TRgb.

Return value

TInt

The greyscale value is calculated using c=(2*r+5*g+b)/8. Note that the return value is rounded down to the nearest integer.


Color16()

TInt Color16() const;

Description

Gets a 4 bit index into a colour palette from this TRgb.

Return value

TInt

The EGA low colour constant closest to the TRgb.


Color256()

TInt Color256() const;

Description

Gets an 8 bit index into a colour palette from this TRgb.

Return value

TInt

An 8 bit index.


Color4K()

TInt Color4K() const;

Description

Gets a 12 bit index into a colour palette from this TRgb.

Return value

TInt

A 12 bit index.


Color16M()

TInt Color16M() const;

Description

Gets a 16 bit index into a colour palette from this TRgb.

Return value

TInt

A 16 bit index.


Color64K()

TInt Color64K() const;

Description

Gets a 24 bit index into a colour palette from this TRgb.

Return value

TInt

A 24 bit index.

[Top]


Comparison


operator==()

TBool operator==(const TRgb& aColor) const;

Description

Compares this colour with the specified colour for equality.

For two colours to be equal, their red, green and blue components must all be equal.

Parameters

const TRgb& aColor

Colour to be compared.

Return value

TBool

True. if the colours are equal; false, otherwise.


operator!=()

TBool operator!=(const TRgb& aColor) const;

Description

Compares this colour with the specified colour for inequality.

Two colours are unequal if one at least one of their red, green and blue components are unequal.

Parameters

const TRgb& aColor

Colour to be compared.

Return value

TBool

True, if the colours are not equal; false, otherwise.


Difference()

TInt Difference(const TRgb& aColor) const;

Description

Gets the difference between two TRgbs.

This difference is defined as the sum of the absolute values of the difference in the red, green and blue components.

Parameters

const TRgb& aColor

The TRgb to be compared.

Return value

TInt

The sum of the absolute value of the differences between the red, green and blue components.

[Top]


Logical operations


operator&()

TRgb operator&(const TRgb& aColor);

Description

Bitwise logical AND operator.

Parameters

const TRgb& aColor

Colour to be compared.

Return value

TRgb

Contains results of logical AND.


operator|()

TRgb operator|(const TRgb& aColor);

Description

Bitwise logical OR operator.

Parameters

const TRgb& aColor

Colour to be compared.

Return value

TRgb

Contains results of logical OR.


operator^()

TRgb operator^(const TRgb& aColor);

Description

Bitwise EXCLUSIVE OR operator

Parameters

const TRgb& aColor

Colour to be compared.

Return value

TRgb

Contains results of logical EXCLUSIVE OR.


operator~()

TRgb operator~() const;

Description

Bitwise logical inversion operator.

Return value

TRgb

Contains results of logical inversion.


operator&=()

TRgb& operator&=(const TRgb& aColor);

Description

Logical AND assignment operator.

The operator ANDs the first operand with the second and then assigns the result back to the first operand.

Note:

Parameters

const TRgb& aColor

Colour to be compared.

Return value

TRgb&

First operand — contains result of logical AND.


operator|=()

TRgb& operator|=(const TRgb& aColor);

Description

Logical OR assignment operator.

The operator ORs the first operand with the second and then assigns the result back to the first operand.

Note:

Parameters

const TRgb& aColor

Colour to be compared.

Return value

TRgb&

First operand — contains result of logical OR.


operator^=()

TRgb& operator^=(const TRgb& aColor);

Description

Logical EXCLUSIVE OR assignment operator.

The operator Exclusive ORs the first operand with the second and then assigns the result back to the first operand.

Note:

Parameters

const TRgb& aColor

Colour to be compared.

Return value

TRgb&

First operand — contains result of logical Exclusive OR.

[Top]


Streaming


InternalizeL()

void InternalizeL(RReadStream& aStream);

Description

Internalises a TRgb object from a stream.

The presence of this function means that the standard templated stream operator>>() is available to internalise objects of this class.

Parameters

RReadStream& aStream

Stream from which the object is internalised.

See also:


ExternalizeL()

void ExternalizeL(RWriteStream& aStream) const;

Description

Externalises a TRgb object to a stream.

The presence of this function means that the standard templated stream operator<<() is available to externalise objects of this class.

Parameters

RWriteStream& aStream

Stream to which the object is externalised.

See also: