Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcolor.cpp File Reference

(fc00dca1c388ee04401d2e391f74b38d42c177df)

#include "qcolor.h"
#include "qcolor_p.h"
#include "qdrawhelper_p.h"
#include "qfloat16.h"
#include "qnamespace.h"
#include "qdatastream.h"
#include "qvariant.h"
#include "qdebug.h"
#include "private/qtools_p.h"
#include <algorithm>
#include <optional>
#include <stdio.h>
#include <limits.h>
Include dependency graph for qcolor.cpp:

Go to the source code of this file.

Classes

struct  RGBData

Namespaces

namespace  QColorConstants
 \inmodule QtGui

Macros

#define rgb(r, g, b)
#define QCOLOR_INT_RANGE_CHECK(fn, var)
#define QCOLOR_REAL_RANGE_CHECK(fn, var)
#define QRGB(r, g, b)
#define QRGBA(r, g, b, a)
#define Q_MAX_3(a, b, c)
#define Q_MIN_3(a, b, c)

Functions

static int hex2int (const char *s, int n)
static std::optional< QRgba64get_hex_rgb (const char *name, size_t len)
std::optional< QRgbqt_get_hex_rgb (const char *name)
static std::optional< QRgba64get_hex_rgb (const QChar *str, size_t len)
static std::optional< QRgba64get_hex_rgb (QAnyStringView name)
bool operator< (const char *name, const RGBData &data)
bool operator< (const RGBData &data, const char *name)
static std::optional< QRgbget_named_rgb_no_space (const char *name_no_space)
static std::optional< QRgbget_named_rgb (QAnyStringView name)
static QStringList get_colornames ()
static qfloat16castF16 (quint16 &v)
static const qfloat16castF16 (const quint16 &v)
QDebug operator<< (QDebug dbg, const QColor &c)
QDataStreamoperator<< (QDataStream &stream, const QColor &color)
QDataStreamoperator>> (QDataStream &stream, QColor &color)

Variables

 QT_BEGIN_NAMESPACE
static constexpr struct RGBData rgbTbl []
static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData)
const uint qt_inv_premul_factor [256]

Macro Definition Documentation

◆ Q_MAX_3

#define Q_MAX_3 ( a,
b,
c )
Value:
( ( a > b && a > c) ? a : (b > c ? b : c) )
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
const GLubyte * c

Definition at line 2177 of file qcolor.cpp.

◆ Q_MIN_3

#define Q_MIN_3 ( a,
b,
c )
Value:
( ( a < b && a < c) ? a : (b < c ? b : c) )

Definition at line 2178 of file qcolor.cpp.

◆ QCOLOR_INT_RANGE_CHECK

#define QCOLOR_INT_RANGE_CHECK ( fn,
var )
Value:
do { \
if (var < 0 || var > 255) { \
qWarning(#fn": invalid value %d", var); \
var = qMax(0, qMin(var, 255)); \
} \
} while (0)
static int qMax(int i1, int i2, int i3)
QT_BEGIN_NAMESPACE constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:19

Definition at line 579 of file qcolor.cpp.

◆ QCOLOR_REAL_RANGE_CHECK

#define QCOLOR_REAL_RANGE_CHECK ( fn,
var )
Value:
do { \
if (var < 0.0f || var > 1.0f) { \
qWarning(#fn": invalid value %g", var); \
var = qMax(0.0f, qMin(var, 1.0f)); \
} \
} while (0)

Definition at line 587 of file qcolor.cpp.

◆ QRGB

#define QRGB ( r,
g,
b )
Value:
QRgb(((0xffu << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff)))
GLboolean r
GLboolean GLboolean g
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
Definition qrgb.h:13

◆ QRGBA

#define QRGBA ( r,
g,
b,
a )
Value:
QRgb(((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff))

◆ rgb

#define rgb ( r,
g,
b )
Value:
(0xff000000 | (r << 16) | (g << 8) | b)

Definition at line 124 of file qcolor.cpp.

Function Documentation

◆ castF16() [1/2]

const qfloat16 & castF16 ( const quint16 & v)
inlinestatic

Definition at line 1235 of file qcolor.cpp.

◆ castF16() [2/2]

qfloat16 & castF16 ( quint16 & v)
inlinestatic

Definition at line 1229 of file qcolor.cpp.

◆ get_colornames()

QStringList get_colornames ( )
static

Definition at line 333 of file qcolor.cpp.

References RGBData::name, and rgbTblSize.

◆ get_hex_rgb() [1/3]

std::optional< QRgba64 > get_hex_rgb ( const char * name,
size_t len )
static

Definition at line 48 of file qcolor.cpp.

◆ get_hex_rgb() [2/3]

std::optional< QRgba64 > get_hex_rgb ( const QChar * str,
size_t len )
static

Definition at line 97 of file qcolor.cpp.

◆ get_hex_rgb() [3/3]

std::optional< QRgba64 > get_hex_rgb ( QAnyStringView name)
static

Definition at line 108 of file qcolor.cpp.

◆ get_named_rgb()

std::optional< QRgb > get_named_rgb ( QAnyStringView name)
static

Definition at line 314 of file qcolor.cpp.

◆ get_named_rgb_no_space()

std::optional< QRgb > get_named_rgb_no_space ( const char * name_no_space)
static

Definition at line 300 of file qcolor.cpp.

References operator<(), rgbTblSize, and RGBData::value.

Here is the call graph for this function:

◆ hex2int()

int hex2int ( const char * s,
int n )
inlinestatic

If s[0..n] is a valid hex number, returns its integer value, otherwise returns -1.

Definition at line 33 of file qcolor.cpp.

◆ operator<() [1/2]

bool operator< ( const char * name,
const RGBData & data )
inline

Definition at line 295 of file qcolor.cpp.

References RGBData::name.

Referenced by get_named_rgb_no_space().

Here is the caller graph for this function:

◆ operator<() [2/2]

bool operator< ( const RGBData & data,
const char * name )
inline

Definition at line 297 of file qcolor.cpp.

References RGBData::name.

◆ operator<<() [1/2]

QDataStream & operator<< ( QDataStream & stream,
const QColor & color )

Definition at line 2975 of file qcolor.cpp.

◆ operator<<() [2/2]

QDebug operator<< ( QDebug dbg,
const QColor & c )

Definition at line 2945 of file qcolor.cpp.

◆ operator>>()

QDataStream & operator>> ( QDataStream & stream,
QColor & color )

Definition at line 3011 of file qcolor.cpp.

◆ qt_get_hex_rgb()

std::optional< QRgb > qt_get_hex_rgb ( const char * name)

Definition at line 90 of file qcolor.cpp.

Variable Documentation

◆ QT_BEGIN_NAMESPACE

QT_BEGIN_NAMESPACE
related

Definition at line 25 of file qcolor.cpp.

◆ qt_inv_premul_factor

const uint qt_inv_premul_factor

Definition at line 3047 of file qcolor.cpp.

◆ rgbTbl

constexpr struct RGBData rgbTbl
static

◆ rgbTblSize

const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData)
static

Definition at line 281 of file qcolor.cpp.

Referenced by get_colornames(), and get_named_rgb_no_space().