Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qcmyk_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 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
4#ifndef QCMYK_P_H
5#define QCMYK_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtGui/private/qtguiglobal_p.h>
19#include <QtGui/qcolor.h>
20
22
24{
25private:
26 uint m_cmyk = 0;
27
28public:
29 QCmyk32() = default;
30
31 constexpr QCmyk32(int cyan, int magenta, int yellow, int black) :
32#if QT_BYTE_ORDER == Q_BIG_ENDIAN
33 m_cmyk(cyan << 24 | magenta << 16 | yellow << 8 | black)
34#else
35 m_cmyk(cyan | magenta << 8 | yellow << 16 | black << 24)
36#endif
37 {
38 }
39
40#if QT_BYTE_ORDER == Q_BIG_ENDIAN
41 constexpr int cyan() const noexcept { return (m_cmyk >> 24) & 0xff; }
42 constexpr int magenta() const noexcept { return (m_cmyk >> 16) & 0xff; }
43 constexpr int yellow() const noexcept { return (m_cmyk >> 8) & 0xff; }
44 constexpr int black() const noexcept { return (m_cmyk ) & 0xff; }
45#else
46 constexpr int cyan() const noexcept { return (m_cmyk ) & 0xff; }
47 constexpr int magenta() const noexcept { return (m_cmyk >> 8) & 0xff; }
48 constexpr int yellow() const noexcept { return (m_cmyk >> 16) & 0xff; }
49 constexpr int black() const noexcept { return (m_cmyk >> 24) & 0xff; }
50#endif
51
52 QColor toColor() const noexcept
53 {
54 return QColor::fromCmyk(cyan(), magenta(), yellow(), black());
55 }
56
57 constexpr uint toUint() const noexcept
58 {
59 return m_cmyk;
60 }
61
62 constexpr static QCmyk32 fromCmyk32(uint cmyk) noexcept
63 {
65 result.m_cmyk = cmyk;
66 return result;
67 }
68
69 static QCmyk32 fromRgba(QRgb rgba) noexcept
70 {
71 const QColor c = QColor(rgba).toCmyk();
72 return QCmyk32(c.cyan(), c.magenta(), c.yellow(), c.black());
73 }
74
75 static QCmyk32 fromColor(const QColor &color) noexcept
76 {
77 QColor c = color.toCmyk();
78 return QCmyk32(c.cyan(), c.magenta(), c.yellow(), c.black());
79 }
80};
81
82static_assert(sizeof(QCmyk32) == sizeof(int));
83static_assert(alignof(QCmyk32) == alignof(int));
84static_assert(std::is_standard_layout_v<QCmyk32>);
85
87
88#endif // QCMYK_P_H
constexpr uint toUint() const noexcept
Definition qcmyk_p.h:57
static constexpr QCmyk32 fromCmyk32(uint cmyk) noexcept
Definition qcmyk_p.h:62
constexpr QCmyk32(int cyan, int magenta, int yellow, int black)
Definition qcmyk_p.h:31
constexpr int black() const noexcept
Definition qcmyk_p.h:44
static QCmyk32 fromRgba(QRgb rgba) noexcept
Definition qcmyk_p.h:69
constexpr int magenta() const noexcept
Definition qcmyk_p.h:42
constexpr int yellow() const noexcept
Definition qcmyk_p.h:43
constexpr int cyan() const noexcept
Definition qcmyk_p.h:41
static QCmyk32 fromColor(const QColor &color) noexcept
Definition qcmyk_p.h:75
QColor toColor() const noexcept
Definition qcmyk_p.h:52
QCmyk32()=default
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
static QColor fromCmyk(int c, int m, int y, int k, int a=255)
Static convenience function that returns a QColor constructed from the given CMYK color values: c (cy...
Definition qcolor.cpp:2741
QColor toCmyk() const noexcept
Creates and returns a CMYK QColor based on this color.
Definition qcolor.cpp:2295
Combined button and popup list for selecting options.
GLuint color
[2]
const GLubyte * c
GLuint64EXT * result
[6]
#define Q_BIG_ENDIAN
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
Definition qrgb.h:13
unsigned int uint
Definition qtypes.h:34
if(qFloatDistance(a, b)<(1<< 7))
[0]