47 #if defined(Q_WS_WINCE) 77 screenMap->
depth = GetDeviceCaps(dc, BITSPIXEL);
80 if (GetDeviceCaps(dc, RASTERCAPS) & RC_PALETTE)
81 screenMap->
numcolors = GetDeviceCaps(dc, SIZEPALETTE);
87 int numPalEntries = 6*6*6;
89 pal = (LOGPALETTE*)malloc(
sizeof(LOGPALETTE) + numPalEntries *
sizeof(PALETTEENTRY));
92 for(
int ir = 0x0; ir <= 0xff; ir+=0x33) {
93 for(
int ig = 0x0; ig <= 0xff; ig+=0x33) {
94 for(
int ib = 0x0; ib <= 0xff; ib+=0x33) {
95 pal->palPalEntry[idx].peRed = ir;
96 pal->palPalEntry[idx].peGreen = ig;
97 pal->palPalEntry[idx].peBlue = ib;
98 pal->palPalEntry[idx].peFlags = 0;
104 pal->palVersion = 0x300;
105 pal->palNumEntries = numPalEntries;
107 screenMap->
hpal = CreatePalette(pal);
108 if (!screenMap->
hpal)
109 qErrnoWarning(
"QColor::initialize: Failed to create logical palette");
112 SelectPalette(dc, screenMap->
hpal,
FALSE);
115 PALETTEENTRY paletteEntries[256];
116 screenMap->
numcolors = GetPaletteEntries(screenMap->
hpal, 0, 255, paletteEntries);
119 for (
int i = 0; i < screenMap->
numcolors; i++) {
120 screenMap->
palette[i] =
qRgb(paletteEntries[i].peRed,
121 paletteEntries[i].peGreen,
122 paletteEntries[i].peBlue);
131 if (screenMap->
hpal) {
132 DeleteObject(screenMap->
hpal);
143 "A QApplication object needs to be constructed before QColormap is used.");
168 {
return d->numcolors; }
182 if (pixel <
uint(
d->numcolors))
183 return d->palette.at(pixel);
186 return QColor(GetRValue(pixel), GetGValue(pixel), GetBValue(pixel));
191 {
return screenMap ? screenMap->
hpal : 0; }
195 {
return d->palette; }
The QColor class provides colors based on RGB, HSV or CMYK values.
static QColormap instance(int screen=-1)
#define QT_END_NAMESPACE
This macro expands to.
The QAtomicInt class provides platform-independent atomic operations on integers. ...
ushort red
Returns the red color component of this color.
QVector< QColor > palette
void resize(int size)
Sets the size of the vector to size.
#define QT_BEGIN_NAMESPACE
This macro expands to.
const QColor colorAt(uint pixel) const
QColormap & operator=(const QColormap &colormap)
#define FALSE
Synonym for false.
Q_GUI_EXPORT HDC qt_win_display_dc()
uint pixel(const QColor &color) const
QColor toRgb() const
Create and returns an RGB QColor based on this color.
#define Q_ASSERT_X(cond, where, what)
ushort blue
Returns the blue color component of this color.
const QVector< QColor > colormap() const
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
void qAtomicAssign(T *&d, T *x)
This is a helper for the assignment operators of implicitly shared classes.
QColormap()
Constructs a new colormap.
static QColormapPrivate * screenMap
ushort green
Returns the green color component of this color.
void qErrnoWarning(const char *msg,...)