8#include <QtGui/qtguiglobal.h>
9#include <QtCore/qprocessordetection.h>
19#if Q_BYTE_ORDER == Q_BIG_ENDIAN
44 return fromRgba64(quint64(red) << RedShift
45 | quint64(green) << GreenShift
46 | quint64(blue) << BlueShift
47 | quint64(alpha) << AlphaShift);
49 constexpr static QRgba64 fromRgba(quint8 red, quint8 green, quint8 blue, quint8 alpha)
51 QRgba64 rgb64 = fromRgba64(red, green, blue, alpha);
53 rgb64.rgba |= rgb64.rgba << 8;
59 return fromRgba(quint8(rgb >> 16), quint8(rgb >> 8), quint8(rgb), quint8(rgb >> 24));
64 return (rgba & alphaMask()) == alphaMask();
68 return (rgba & alphaMask()) == 0;
71 constexpr quint16 red()
const {
return quint16(rgba >> RedShift); }
72 constexpr quint16 green()
const {
return quint16(rgba >> GreenShift); }
73 constexpr quint16 blue()
const {
return quint16(rgba >> BlueShift); }
74 constexpr quint16 alpha()
const {
return quint16(rgba >> AlphaShift); }
75 void setRed(quint16 _red) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << RedShift)) | (quint64(_red) << RedShift); }
76 void setGreen(quint16 _green) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << GreenShift)) | (quint64(_green) << GreenShift); }
77 void setBlue(quint16 _blue) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << BlueShift)) | (quint64(_blue) << BlueShift); }
78 void setAlpha(quint16 _alpha) { rgba = (rgba & ~(Q_UINT64_C(0xffff) << AlphaShift)) | (quint64(_alpha) << AlphaShift); }
86 quint64 br = rgba & Q_UINT64_C(0xffff0000ffff);
87 quint64 ag = (rgba >> 16) & Q_UINT64_C(0xffff0000ffff);
88 br += Q_UINT64_C(0x8000000080);
89 ag += Q_UINT64_C(0x8000000080);
90 br = (br - ((br >> 8) & Q_UINT64_C(0xffff0000ffff))) >> 8;
91 ag = (ag - ((ag >> 8) & Q_UINT64_C(0xffff0000ffff)));
92#if Q_BYTE_ORDER == Q_BIG_ENDIAN
93 return ((br << 24) & 0xff000000)
94 | ((ag >> 24) & 0xff0000)
95 | ((br >> 24) & 0xff00)
98 return ((ag >> 16) & 0xff000000)
99 | ((br << 16) & 0xff0000)
101 | ((br >> 32) & 0xff);
106 return ushort((red() & 0xf800) | ((green() >> 10) << 5) | (blue() >> 11));
114 return QRgba64::fromRgba64(0);
115 const quint64 a = alpha();
116 quint64 br = (rgba & Q_UINT64_C(0xffff0000ffff)) * a;
117 quint64 ag = ((rgba >> 16) & Q_UINT64_C(0xffff0000ffff)) * a;
118 br = (br + ((br >> 16) & Q_UINT64_C(0xffff0000ffff)) + Q_UINT64_C(0x800000008000));
119 ag = (ag + ((ag >> 16) & Q_UINT64_C(0xffff0000ffff)) + Q_UINT64_C(0x800000008000));
120#if Q_BYTE_ORDER == Q_BIG_ENDIAN
121 ag = ag & Q_UINT64_C(0xffff0000ffff0000);
122 br = (br >> 16) & Q_UINT64_C(0xffff00000000);
123 return fromRgba64(a | br | ag);
125 br = (br >> 16) & Q_UINT64_C(0xffff0000ffff);
126 ag = ag & Q_UINT64_C(0xffff0000);
127 return fromRgba64((a << 48) | br | ag);
133#if Q_PROCESSOR_WORDSIZE < 8
134 return unpremultiplied_32bit();
136 return unpremultiplied_64bit();
183 return QRgba64::fromRgba64(r, g, b, a);
188 return QRgba64::fromRgba64(c);
202{
return rgb.red8(); }
205{
return rgb.green8(); }
208{
return rgb.blue8(); }
211{
return rgb.alpha8(); }
constexpr ushort toRgb16() const
static constexpr QRgba64 fromRgba64(quint16 red, quint16 green, quint16 blue, quint16 alpha)
constexpr quint16 red() const
constexpr quint8 blue8() const
constexpr quint16 alpha() const
constexpr QRgba64 unpremultiplied() const
constexpr quint16 green() const
constexpr quint16 blue() const
static constexpr QRgba64 fromRgba64(quint64 c)
void setAlpha(quint16 _alpha)
constexpr uint toArgb32() const
static constexpr QRgba64 fromRgba(quint8 red, quint8 green, quint8 blue, quint8 alpha)
constexpr quint8 red8() const
constexpr bool isOpaque() const
constexpr quint8 green8() const
constexpr quint8 alpha8() const
void setGreen(quint16 _green)
void setBlue(quint16 _blue)
static constexpr QRgba64 fromArgb32(uint rgb)
void setRed(quint16 _red)
constexpr bool isTransparent() const
constexpr QRgba64 premultiplied() const
Combined button and popup list for selecting options.
#define qCWarning(category,...)
static bool write_pbm_image(QIODevice *out, const QImage &sourceImage, QByteArrayView sourceFormat)
static bool read_pbm_header(QIODevice *device, char &type, int &w, int &h, quint16 &mcc)
static quint16 read_pbm_int(QIODevice *d, bool *ok, int maxDigits=-1)
static bool read_pbm_body(QIODevice *device, char type, int w, int h, quint16 mcc, QImage *outImage)
static QRgb scale_pbm_color(quint16 mx, quint16 rv, quint16 gv, quint16 bv)
static QT_BEGIN_NAMESPACE void discard_pbm_line(QIODevice *d)
constexpr uint qBlue(QRgba64 rgb)
constexpr QRgba64 qRgba64(quint64 c)
constexpr QRgba64 qUnpremultiply(QRgba64 c)
constexpr QRgba64 qRgba64(quint16 r, quint16 g, quint16 b, quint16 a)
constexpr uint qAlpha(QRgba64 rgb)
constexpr QRgba64 qPremultiply(QRgba64 c)
constexpr uint qRed(QRgba64 rgb)
constexpr uint qGreen(QRgba64 rgb)
Q_DECLARE_TYPEINFO(QRgba64, Q_PRIMITIVE_TYPE)