XMCOLOR structure (directxpackedvector.h)

A 32-bit Alpha Red Green Blue (ARGB) color vector, where each color channel is specified as an unsigned 8 bit integer.

For a list of additional functionality such as constructors and operators that are available using XMCOLOR when you are programming in C++, see XMCOLOR Extensions.

Note  See DirectXMath Library Type Equivalences for information about equivalent D3DDECLTYPE, D3DFORMAT,and DXGI_FORMAT objects.
 

Syntax

struct XMCOLOR {
  union {
    struct {
      uint8_t b;
      uint8_t g;
      uint8_t r;
      uint8_t a;
    };
             uint32_t c;
  };
  void      XMCOLOR();
  void      XMCOLOR(
    const XMCOLOR & unnamedParam1
  );
  XMCOLOR & operator=(
    const XMCOLOR & unnamedParam1
  );
  void      XMCOLOR(
    XMCOLOR && unnamedParam1
  );
  XMCOLOR & operator=(
    XMCOLOR && unnamedParam1
  );
  void      XMCOLOR(
    uint32_t Color
  ) noexcept;
  void      XMCOLOR(
    float _r,
    float _g,
    float _b,
    float _a
  ) noexcept;
  void      XMCOLOR(
    const float *pArray
  ) noexcept;
  void      operator uint32_t() noexcept;
  XMCOLOR & operator=(
    const uint32_t Color
  ) noexcept;
};

Members

b

Unsigned integer between 0 and 255 representing the blue component.

g

Unsigned integer between 0 and 255 representing the green component.

r

Unsigned integer between 0 and 255 representing the red component.

a

Unsigned integer between 0 and 255 representing the alpha component.

c

Unsigned 32-bit integer representing the color. The colors are stored in A8R8G8B8 format.

The alpha component the most-significant bits, and the blue component is stored in the least-significant bits.

void XMCOLOR()

Default constructor for XMCOLOR

Default constructor for XMCOLOR

Note  This is only available for C++ based development.
 

void XMCOLOR( const XMCOLOR & unnamedParam1)

A constructor for XMCOLOR

A constructor for XMCOLOR

Note  This is only available for C++ based development.

XMCOLOR & operator=( const XMCOLOR & unnamedParam1)

void XMCOLOR( XMCOLOR && unnamedParam1)

A constructor for XMCOLOR

A constructor for XMCOLOR

Note  This is only available for C++ based development.

XMCOLOR & operator=( XMCOLOR && unnamedParam1)

This operator assigns the vector component data from one instance of XMCOLOR to the current instance of XMCOLOR.

Note  This operator is only available under C++.

void XMCOLOR( uint32_t Color) noexcept

Initializes a new instance of XMCOLOR from a uint32_t variable containing component data in a packed format.

This constructor initializes a new instance of XMCOLOR from a uint32_t variable containing component data in a packed format.

Note  This constructor is only available under C++.
 

void XMCOLOR( float _r, float _g, float _b, float _a) noexcept

Initializes a new instance of XMCOLOR from four float arguments.

This constructor initializes a new instance of XMCOLOR from four float arguments.

Note  This constructor is only available under C++.
 

void XMCOLOR( const float *pArray) noexcept

Initializes a new instance of XMCOLOR from a four element float array argument.

This constructor initializes a new instance of XMCOLOR from a from a four element float array argument.

Note  This is only available for C++ based development.

void operator uint32_t() noexcept

Returns an instance of uint32_t containing the components of the XMCOLOR instance in a packed format.

Note  This operator is only available under C++.
 

XMCOLOR & operator=( const uint32_t Color) noexcept

Assigns the vector component data packed in an instance of uint32_t to the current instance of XMCOLOR.

This operator assigns the vector component data packed in an instance of uint32_t to the current instance of XMCOLOR.

Note  This operator is only available under C++.
 

Remarks

Those XMCOLOR constructors using floating point arguments require normalized input, which are clamped to the range of [0-1.0]. During instantiation, the floating point data specifying the color channels are multiplied by 255.0f, rounded and then assigned to the appropriate members of XMCOLOR.

XMCOLOR can be used to load instances of XMVECTOR from normalized values, by using XMLoadColor, which divides color channel data by 255.0f, rounds the result, and then assigns the components to an XMVECTOR instance.

XMVECTOR instances containing normalized values can be stored into XMCOLOR using XMStoreColor, which multiplies color channel data by 255.0f, rounding the result before assigning the values to the appropriate XMCOLOR members.

Namespace: Use DirectX::PackedVector

Platform Requirements

Microsoft Visual Studio 2010 or Microsoft Visual Studio 2012 with the Windows SDK for Windows 8. Supported for Win32 desktop apps, Windows Store apps, and Windows Phone 8 apps.

Requirements

Requirement Value
Header directxpackedvector.h

See also

DirectXMath Library Structures

XMCOLOR Extensions