Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qrgb.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
QRGB_H
6
#
define
QRGB_H
7
8
#
include
<
QtGui
/
qtguiglobal
.
h
>
9
#
include
<
QtCore
/
qprocessordetection
.
h
>
10
11
QT_BEGIN_NAMESPACE
12
13
14
typedef
unsigned
int
QRgb
;
// RGB triplet
15
16
// non-namespaced Qt global variable
17
inline
constexpr
QRgb
RGB_MASK
= 0x00ffffff;
// masks RGB values
18
19
inline
constexpr
int
qRed
(
QRgb
rgb)
// get red part of RGB
20
{
return
((rgb >> 16) & 0xff); }
21
22
inline
constexpr
int
qGreen
(
QRgb
rgb)
// get green part of RGB
23
{
return
((rgb >> 8) & 0xff); }
24
25
inline
constexpr
int
qBlue
(
QRgb
rgb)
// get blue part of RGB
26
{
return
(rgb & 0xff); }
27
28
inline
constexpr
int
qAlpha
(
QRgb
rgb)
// get alpha part of RGBA
29
{
return
rgb >> 24; }
30
31
inline
constexpr
QRgb
qRgb
(
int
r,
int
g,
int
b)
// set RGB value
32
{
return
(0xffu << 24) | ((r & 0xffu) << 16) | ((g & 0xffu) << 8) | (b & 0xffu); }
33
34
inline
constexpr
QRgb
qRgba
(
int
r,
int
g,
int
b,
int
a)
// set RGBA value
35
{
return
((a & 0xffu) << 24) | ((r & 0xffu) << 16) | ((g & 0xffu) << 8) | (b & 0xffu); }
36
37
inline
constexpr
int
qGray
(
int
r,
int
g,
int
b)
// convert R,G,B to gray 0..255
38
{
return
(r*11+g*16+b*5)/32; }
39
40
inline
constexpr
int
qGray
(
QRgb
rgb)
// convert RGB to gray 0..255
41
{
return
qGray
(
qRed
(
rgb
)
,
qGreen
(
rgb
)
,
qBlue
(
rgb
)
)
; }
42
43
inline
constexpr
bool
qIsGray
(
QRgb
rgb)
44
{
return
qRed
(
rgb
)
==
qGreen
(
rgb
)
&&
qRed
(
rgb
)
==
qBlue
(
rgb
)
; }
45
46
inline
constexpr
QRgb
qPremultiply
(
QRgb
x)
47
{
48
const
uint a =
qAlpha
(
x
)
;
49
uint t = (x & 0xff00ff) * a;
50
t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;
51
t &= 0xff00ff;
52
53
x = ((x >> 8) & 0xff) * a;
54
x = (x + ((x >> 8) & 0xff) + 0x80);
55
x &= 0xff00;
56
return
x | t | (a << 24);
57
}
58
59
Q_GUI_EXPORT
extern
const
uint qt_inv_premul_factor[];
60
61
inline
QRgb
qUnpremultiply
(
QRgb
p)
62
{
63
const
uint alpha =
qAlpha
(
p
)
;
64
// Alpha 255 and 0 are the two most common values, which makes them beneficial to short-cut.
65
if
(alpha == 255)
66
return
p;
67
if
(alpha == 0)
68
return
0;
69
// (p*(0x00ff00ff/alpha)) >> 16 == (p*255)/alpha for all p and alpha <= 256.
70
const
uint invAlpha = qt_inv_premul_factor[alpha];
71
// We add 0x8000 to get even rounding. The rounding also ensures that qPremultiply(qUnpremultiply(p)) == p for all p.
72
return
qRgba((
qRed
(
p
)
*invAlpha + 0x8000)>>16, (
qGreen
(
p
)
*invAlpha + 0x8000)>>16, (
qBlue
(
p
)
*invAlpha + 0x8000)>>16, alpha);
73
}
74
75
QT_END_NAMESPACE
76
77
#
endif
// QRGB_H
QOpenGL2PaintEngineExPrivate
Definition
qopenglpaintengine_p.h:141
QOpenGLFunctions
The QOpenGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
Definition
qopenglfunctions.h:202
QOpenGLGlyphTexture
Definition
qopengltextureglyphcache_p.h:34
QOpenGLGlyphTexture::invalidateResource
void invalidateResource() override
Definition
qopengltextureglyphcache_p.h:61
QOpenGLGlyphTexture::m_height
int m_height
Definition
qopengltextureglyphcache_p.h:72
QOpenGLGlyphTexture::freeResource
void freeResource(QOpenGLContext *context) override
Definition
qopengltextureglyphcache_p.h:49
QOpenGLGlyphTexture::m_texture
GLuint m_texture
Definition
qopengltextureglyphcache_p.h:69
QOpenGLGlyphTexture::QOpenGLGlyphTexture
QOpenGLGlyphTexture(QOpenGLContext *ctx)
Definition
qopengltextureglyphcache_p.h:36
QOpenGLGlyphTexture::m_width
int m_width
Definition
qopengltextureglyphcache_p.h:71
QOpenGLGlyphTexture::m_fbo
GLuint m_fbo
Definition
qopengltextureglyphcache_p.h:70
QOpenGLTextureGlyphCache
Definition
qopengltextureglyphcache_p.h:76
QOpenGLVertexArrayObject
The QOpenGLVertexArrayObject class wraps an OpenGL Vertex Array Object.
Definition
qopenglvertexarrayobject.h:20
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
load_glyph_image_region_to_texture
static void load_glyph_image_region_to_texture(QOpenGLContext *ctx, const QImage &srcImg, int x, int y, int w, int h, GLuint texture, int tx, int ty)
Definition
qopengltextureglyphcache.cpp:223
load_glyph_image_to_texture
static void load_glyph_image_to_texture(QOpenGLContext *ctx, QImage &img, GLuint texture, int tx, int ty)
Definition
qopengltextureglyphcache.cpp:153
next_qopengltextureglyphcache_serial_number
static QT_BEGIN_NAMESPACE int next_qopengltextureglyphcache_serial_number()
Definition
qopengltextureglyphcache.cpp:15
qGray
constexpr int qGray(QRgb rgb)
Definition
qrgb.h:40
qIsGray
constexpr bool qIsGray(QRgb rgb)
Definition
qrgb.h:43
QRgb
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
Definition
qrgb.h:14
qRgb
constexpr QRgb qRgb(int r, int g, int b)
Definition
qrgb.h:31
qRed
constexpr int qRed(QRgb rgb)
Definition
qrgb.h:19
qGreen
constexpr int qGreen(QRgb rgb)
Definition
qrgb.h:22
qGray
constexpr int qGray(int r, int g, int b)
Definition
qrgb.h:37
qUnpremultiply
QRgb qUnpremultiply(QRgb p)
Definition
qrgb.h:61
qRgba
constexpr QRgb qRgba(int r, int g, int b, int a)
Definition
qrgb.h:34
qBlue
constexpr int qBlue(QRgb rgb)
Definition
qrgb.h:25
RGB_MASK
constexpr QRgb RGB_MASK
Definition
qrgb.h:17
qPremultiply
constexpr QRgb qPremultiply(QRgb x)
Definition
qrgb.h:46
qAlpha
constexpr int qAlpha(QRgb rgb)
Definition
qrgb.h:28
qtbase
src
gui
painting
qrgb.h
Generated on
for Qt by
1.18.0