Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qpixmap_win.cpp
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
4#include "qbitmap.h"
5#include "qpixmap.h"
6#include <private/qpixmap_win_p.h>
7#include <qpa/qplatformpixmap.h>
8#include "qpixmap_raster_p.h"
9
10#include <qdebug.h>
11#include <QScopedArrayPointer>
12#include <qt_windows.h>
13
14#include <algorithm>
15#include <iterator>
16
18
19template <typename Int>
20static inline Int pad4(Int v)
21{
22 return (v + Int(3)) & ~Int(3);
23}
24
25#ifndef QT_NO_DEBUG_STREAM
26QDebug operator<<(QDebug d, const BITMAPINFOHEADER &bih)
27{
28 QDebugStateSaver saver(d);
29 d.nospace();
30 d << "BITMAPINFOHEADER(" << bih.biWidth << 'x' << qAbs(bih.biHeight)
31 << (bih.biHeight < 0 ? ", top-down" : ", bottom-up")
32 << ", planes=" << bih.biPlanes << ", bitCount=" << bih.biBitCount
33 << ", compression=" << bih.biCompression << ", size="
34 << bih.biSizeImage << ')';
35 return d;
36}
37#endif // !QT_NO_DEBUG_STREAM
38
39static inline void initBitMapInfoHeader(int width, int height, bool topToBottom,
40 DWORD compression, DWORD bitCount,
41 BITMAPINFOHEADER *bih)
42{
43 memset(bih, 0, sizeof(BITMAPINFOHEADER));
44 bih->biSize = sizeof(BITMAPINFOHEADER);
45 bih->biWidth = width;
46 bih->biHeight = topToBottom ? -height : height;
47 bih->biPlanes = 1;
48 bih->biBitCount = WORD(bitCount);
49 bih->biCompression = compression;
50 // scan lines are word-aligned (unless RLE)
51 const DWORD bytesPerLine = pad4(DWORD(width) * bitCount / 8);
52 bih->biSizeImage = bytesPerLine * DWORD(height);
53}
54
56
57struct BITMAPINFO_COLORTABLE256 { // BITMAPINFO with 256 entry color table for Indexed 8 format
58 BITMAPINFOHEADER bmiHeader;
60};
61
62template <class BITMAPINFO_T> // BITMAPINFO, BITMAPINFO_COLORTABLE256
63static inline void initBitMapInfo(int width, int height, bool topToBottom,
64 DWORD compression, DWORD bitCount,
65 BITMAPINFO_T *bmi)
66{
67 initBitMapInfoHeader(width, height, topToBottom, compression, bitCount, &bmi->bmiHeader);
68 memset(bmi->bmiColors, 0, sizeof(bmi->bmiColors));
69}
70
71static inline uchar *getDiBits(HDC hdc, HBITMAP bitmap, int width, int height, bool topToBottom = true)
72{
73 BITMAPINFO bmi;
74 initBitMapInfo(width, height, topToBottom, BI_RGB, 32u, &bmi);
75 uchar *result = new uchar[bmi.bmiHeader.biSizeImage];
76 if (!GetDIBits(hdc, bitmap, 0, UINT(height), result, &bmi, DIB_RGB_COLORS)) {
77 delete [] result;
78 qErrnoWarning("%s: GetDIBits() failed to get bitmap bits.", __FUNCTION__);
79 return nullptr;
80 }
81 return result;
82}
83
84static inline void copyImageDataCreateAlpha(const uchar *data, QImage *target)
85{
86 const uint mask = target->format() == QImage::Format_RGB32 ? 0xff000000 : 0;
87 const int height = target->height();
88 const int width = target->width();
89 const qsizetype bytesPerLine = width * sizeof(QRgb);
90 for (int y = 0; y < height; ++y) {
91 QRgb *dest = reinterpret_cast<QRgb *>(target->scanLine(y));
92 const QRgb *src = reinterpret_cast<const QRgb *>(data + y * bytesPerLine);
93 for (int x = 0; x < width; ++x) {
94 const uint pixel = src[x];
95 if ((pixel & 0xff000000) == 0 && (pixel & 0x00ffffff) != 0)
96 dest[x] = pixel | 0xff000000;
97 else
98 dest[x] = pixel | mask;
99 }
100 }
101}
102
103// Flip RGB triplets from DIB to QImage formats. Scan lines are padded to 32bit
104// both in QImage and DIB.
105static inline void flipRgb3(uchar *p, int width, int height)
106{
107 const int lineSize = 3 * width;
108 const int linePad = pad4(lineSize) - lineSize;
109 for (int y = 0; y < height; ++y) {
110 uchar *end = p + lineSize;
111 for ( ; p < end; p += 3)
112 std::swap(*p, *(p + 2));
113 p += linePad;
114 }
115}
116
117static inline RGBQUAD qRgbToRgbQuad(QRgb qrgb)
118{
119 RGBQUAD result = {BYTE(qBlue(qrgb)), BYTE(qGreen(qrgb)), BYTE(qRed(qrgb)), 0};
120 return result;
121}
122
123static inline QRgb rgbQuadToQRgb(RGBQUAD quad)
124{
125 return QRgb(quad.rgbBlue) + (QRgb(quad.rgbGreen) << 8) + (QRgb(quad.rgbRed) << 16)
126 + 0xff000000;
127}
128
129// Helper for imageFromWinHBITMAP_*(), create image in desired format
130static QImage copyImageData(const BITMAPINFOHEADER &header, const RGBQUAD *colorTableIn,
131 const void *data, QImage::Format format)
132{
133 const QSize size = QSize(header.biWidth, qAbs(header.biHeight));
135
136 int colorTableSize = 0;
137 switch (format) {
139 colorTableSize = 2;
140 break;
142 colorTableSize = Indexed8ColorTableSize;
143 break;
144 default:
145 break;
146 }
147 if (colorTableSize) {
148 Q_ASSERT(colorTableIn);
149 QList<QRgb> colorTable;
150 colorTable.reserve(colorTableSize);
151 std::transform(colorTableIn, colorTableIn + colorTableSize,
152 std::back_inserter(colorTable), rgbQuadToQRgb);
153 image.setColorTable(colorTable);
154 }
155
156 switch (header.biBitCount) {
157 case 32:
158 copyImageDataCreateAlpha(static_cast<const uchar *>(data), &image);
159 break;
160 case 1:
161 case 8:
162 case 16:
163 case 24:
164 Q_ASSERT(DWORD(image.sizeInBytes()) == header.biSizeImage);
165 memcpy(image.bits(), data, header.biSizeImage);
167 image = image.rgbSwapped();
168 break;
169 default:
170 Q_UNREACHABLE();
171 break;
172 }
173 return image;
174}
175
177{
178 Q_DISABLE_COPY_MOVE(DisplayHdc)
179public:
180 DisplayHdc() : m_displayDc(GetDC(nullptr)) {}
181 ~DisplayHdc() { ReleaseDC(nullptr, m_displayDc); }
182
183 operator HDC() const { return m_displayDc; }
184
185private:
186 const HDC m_displayDc;
187};
188
190{
195
196static HBITMAP qt_createIconMask(QImage bm)
197{
199 const int w = bm.width();
200 const int h = bm.height();
201 const int bpl = ((w+15)/16)*2; // bpl, 16 bit alignment
202 QScopedArrayPointer<uchar> bits(new uchar[size_t(bpl * h)]);
203 bm.invertPixels();
204 for (int y = 0; y < h; ++y)
205 memcpy(bits.data() + y * bpl, bm.constScanLine(y), size_t(bpl));
206 HBITMAP hbm = CreateBitmap(w, h, 1, 1, bits.data());
207 return hbm;
208}
209
211{
212 return qt_createIconMask(bitmap.toImage().convertToFormat(QImage::Format_Mono));
213}
214
215static inline QImage::Format format32(int hbitmapFormat)
216{
217 switch (hbitmapFormat) {
218 case HBitmapNoAlpha:
220 case HBitmapAlpha:
222 default:
223 break;
224 }
226}
227
228HBITMAP qt_imageToWinHBITMAP(const QImage &imageIn, int hbitmapFormat)
229{
230 if (imageIn.isNull())
231 return nullptr;
232
233 // Define the header
234 DWORD compression = 0;
235 DWORD bitCount = 0;
236
237 // Copy over the data
238 QImage image = imageIn;
239 switch (image.format()) {
241 bitCount = 1u;
242 break;
246 compression = BI_RGB;
247 bitCount = 32u;
248 const QImage::Format targetFormat = format32(hbitmapFormat);
249 if (targetFormat != image.format())
250 image = image.convertToFormat(targetFormat);
251 }
252 break;
255 compression = BI_RGB;
256 bitCount = 24u;
257 break;
259 bitCount = 8u;
260 break;
262 bitCount = 16u;
263 break;
264 default: {
266 switch (image.format()) { // Convert to a suitable format.
268 fallbackFormat = QImage::Format_Mono;
269 break;
271 fallbackFormat = QImage::Format_RGB555;
272 break;
274 fallbackFormat = QImage::Format_Indexed8;
275 break;
276 default:
277 break;
278 } // switch conversion format
279 return qt_imageToWinHBITMAP(imageIn.convertToFormat(fallbackFormat), hbitmapFormat);
280 }
281 }
282
283 const int w = image.width();
284 const int h = image.height();
285
286 BITMAPINFO_COLORTABLE256 bmiColorTable256;
287 initBitMapInfo(w, h, true, compression, bitCount, &bmiColorTable256);
288 BITMAPINFO &bmi = reinterpret_cast<BITMAPINFO &>(bmiColorTable256);
289 switch (image.format()) {
290 case QImage::Format_Mono: // Color table with 2 entries
292 std::transform(image.colorTable().constBegin(), image.colorTable().constEnd(),
293 bmiColorTable256.bmiColors, qRgbToRgbQuad);
294 break;
295 default:
296 break;
297 }
298
299 // Create the pixmap
300 uchar *pixels = nullptr;
301 const HBITMAP bitmap = CreateDIBSection(nullptr, &bmi, DIB_RGB_COLORS,
302 reinterpret_cast<void **>(&pixels), nullptr, 0);
303 if (!bitmap) {
304 qErrnoWarning("%s, failed to create dibsection", __FUNCTION__);
305 return nullptr;
306 }
307 if (!pixels) {
308 qErrnoWarning("%s, did not allocate pixel data", __FUNCTION__);
309 return nullptr;
310 }
311 memcpy(pixels, image.constBits(), bmi.bmiHeader.biSizeImage);
312 if (image.format() == QImage::Format_RGB888)
313 flipRgb3(pixels, w, h);
314 return bitmap;
315}
316
341HBITMAP QImage::toHBITMAP() const
342{
343 switch (format()) {
345 return qt_imageToWinHBITMAP(*this, HBitmapAlpha);
348 default:
349 break;
350 }
351 return qt_imageToWinHBITMAP(*this);
352}
353
354HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat)
355{
356 if (p.isNull())
357 return nullptr;
358
359 QPlatformPixmap *platformPixmap = p.handle();
363 data->fromImage(p.toImage(), Qt::AutoColor);
364 return qt_pixmapToWinHBITMAP(QPixmap(data), hbitmapFormat);
365 }
366
367 return qt_imageToWinHBITMAP(*static_cast<QRasterPlatformPixmap*>(platformPixmap)->buffer(), hbitmapFormat);
368}
369
370static QImage::Format imageFromWinHBITMAP_Format(const BITMAPINFOHEADER &header, int hbitmapFormat)
371{
373 switch (header.biBitCount) {
374 case 32:
375 result = hbitmapFormat == HBitmapNoAlpha
377 break;
378 case 24:
380 break;
381 case 16:
383 break;
384 case 8:
386 break;
387 case 1:
389 break;
390 }
391 return result;
392}
393
394// Fast path for creating a QImage directly from a HBITMAP created by CreateDIBSection(),
395// not requiring memory allocation.
396static QImage imageFromWinHBITMAP_DibSection(HBITMAP bitmap, int hbitmapFormat)
397{
398 DIBSECTION dibSection;
399 memset(&dibSection, 0, sizeof(dibSection));
400 dibSection.dsBmih.biSize = sizeof(dibSection.dsBmih);
401
402 if (!GetObject(bitmap, sizeof(dibSection), &dibSection)
403 || !dibSection.dsBm.bmBits
404 || dibSection.dsBmih.biBitCount <= 8 // Cannot access the color table for Indexed8, Mono
405 || dibSection.dsBmih.biCompression != BI_RGB) {
406 return QImage();
407 }
408
409 const QImage::Format imageFormat = imageFromWinHBITMAP_Format(dibSection.dsBmih, hbitmapFormat);
410 if (imageFormat == QImage::Format_Invalid)
411 return QImage();
412
413 return copyImageData(dibSection.dsBmih, nullptr, dibSection.dsBm.bmBits, imageFormat);
414}
415
416// Create QImage from a HBITMAP using GetDIBits(), potentially with conversion.
417static QImage imageFromWinHBITMAP_GetDiBits(HBITMAP bitmap, bool forceQuads, int hbitmapFormat)
418{
419 BITMAPINFO_COLORTABLE256 bmiColorTable256;
420 BITMAPINFO &info = reinterpret_cast<BITMAPINFO &>(bmiColorTable256);
421 memset(&info, 0, sizeof(info));
422 info.bmiHeader.biSize = sizeof(info.bmiHeader);
423
424 DisplayHdc displayDc;
425 if (!GetDIBits(displayDc, bitmap, 0, 1, 0, &info, DIB_RGB_COLORS)) {
426 qErrnoWarning("%s: GetDIBits() failed to query data.", __FUNCTION__);
427 return QImage();
428 }
429
430 if (info.bmiHeader.biHeight > 0) // Force top-down
431 info.bmiHeader.biHeight = -info.bmiHeader.biHeight;
432 info.bmiHeader.biCompression = BI_RGB; // Extract using no compression (can be BI_BITFIELD)
433 size_t allocSize = info.bmiHeader.biSizeImage;
434 if (forceQuads) {
435 info.bmiHeader.biBitCount = 32;
436 allocSize = info.bmiHeader.biWidth * qAbs(info.bmiHeader.biHeight) * 4;
437 }
438
439 const QImage::Format imageFormat = imageFromWinHBITMAP_Format(info.bmiHeader, hbitmapFormat);
440 if (imageFormat == QImage::Format_Invalid) {
441 qWarning().nospace() << __FUNCTION__ << ": unsupported image format:" << info.bmiHeader;
442 return QImage();
443 }
444
445 QScopedArrayPointer<uchar> data(new uchar[allocSize]);
446 if (!GetDIBits(displayDc, bitmap, 0, qAbs(info.bmiHeader.biHeight), data.data(), &info, DIB_RGB_COLORS)) {
447 qErrnoWarning("%s: GetDIBits() failed to get data.", __FUNCTION__);
448 return QImage();
449 }
450 return copyImageData(info.bmiHeader, bmiColorTable256.bmiColors, data.data(), imageFormat);
451}
452
453QImage qt_imageFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat)
454{
456 if (result.isNull())
457 result = imageFromWinHBITMAP_GetDiBits(bitmap, /* forceQuads */ false, hbitmapFormat);
458 return result;
459}
460
480QImage QImage::fromHBITMAP(HBITMAP hbitmap)
481{
482 return qt_imageFromWinHBITMAP(hbitmap);
483}
484
485QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat)
486{
487 return QPixmap::fromImage(imageFromWinHBITMAP_GetDiBits(bitmap, /* forceQuads */ true, hbitmapFormat));
488}
489
505HICON QImage::toHICON(const QImage &mask) const
506{
507 if (!mask.isNull() && mask.format() != QImage::Format_Mono) {
508 qWarning("QImage::toHICON(): Mask must be empty or have format Format_Mono");
509 return nullptr;
510 }
511
512 if (isNull())
513 return nullptr;
514
515 auto effectiveMask = mask;
516 if (effectiveMask.isNull()) {
517 effectiveMask = QImage(size(), QImage::Format_Mono);
518 effectiveMask.fill(Qt::color1);
519 }
520
521 ICONINFO ii;
522 ii.fIcon = true;
523 ii.hbmMask = qt_createIconMask(effectiveMask);
524 ii.hbmColor = qt_imageToWinHBITMAP(*this, HBitmapAlpha);
525 ii.xHotspot = 0;
526 ii.yHotspot = 0;
527
528 HICON hIcon = CreateIconIndirect(&ii);
529
530 DeleteObject(ii.hbmColor);
531 DeleteObject(ii.hbmMask);
532
533 return hIcon;
534}
535
537{
538 QImage mask;
539 QBitmap maskBitmap = p.mask();
540 if (!maskBitmap.isNull())
542 return p.toImage().toHICON(mask);
543}
544
545QImage qt_imageFromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
546{
548 if (image.isNull())
549 return image;
551 if (data.isNull())
552 return QImage();
554 return image;
555}
556
557static QImage qt_imageFromWinIconHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
558{
560 if (image.isNull())
561 return image;
563 if (data.isNull())
564 return QImage();
565 memcpy(image.bits(), data.data(), size_t(image.sizeInBytes()));
566 return image;
567}
568
569static inline bool hasAlpha(const QImage &image)
570{
571 const int w = image.width();
572 const int h = image.height();
573 for (int y = 0; y < h; ++y) {
574 const QRgb *scanLine = reinterpret_cast<const QRgb *>(image.scanLine(y));
575 for (int x = 0; x < w; ++x) {
576 if (qAlpha(scanLine[x]) != 0)
577 return true;
578 }
579 }
580 return false;
581}
582
592QImage QImage::fromHICON(HICON icon)
593{
594 HDC screenDevice = GetDC(nullptr);
595 HDC hdc = CreateCompatibleDC(screenDevice);
596 ReleaseDC(nullptr, screenDevice);
597
598 ICONINFO iconinfo;
599 const bool result = GetIconInfo(icon, &iconinfo); //x and y Hotspot describes the icon center
600 if (!result) {
601 qErrnoWarning("QPixmap::fromWinHICON(), failed to GetIconInfo()");
602 DeleteDC(hdc);
603 return {};
604 }
605
606 const int w = int(iconinfo.xHotspot) * 2;
607 const int h = int(iconinfo.yHotspot) * 2;
608
609 BITMAPINFOHEADER bitmapInfo;
610 initBitMapInfoHeader(w, h, false, BI_RGB, 32u, &bitmapInfo);
611 DWORD* bits;
612
613 HBITMAP winBitmap = CreateDIBSection(hdc, reinterpret_cast<BITMAPINFO *>(&bitmapInfo),
614 DIB_RGB_COLORS, reinterpret_cast<VOID **>(&bits),
615 nullptr, 0);
616 HGDIOBJ oldhdc = static_cast<HBITMAP>(SelectObject(hdc, winBitmap));
617 DrawIconEx(hdc, 0, 0, icon, w, h, 0, nullptr, DI_NORMAL);
618 QImage image = qt_imageFromWinIconHBITMAP(hdc, winBitmap, w, h);
619
620 if (!image.isNull() && !hasAlpha(image)) { //If no alpha was found, we use the mask to set alpha values
621 DrawIconEx( hdc, 0, 0, icon, w, h, 0, nullptr, DI_MASK);
622 const QImage mask = qt_imageFromWinIconHBITMAP(hdc, winBitmap, w, h);
623
624 for (int y = 0 ; y < h ; y++){
625 QRgb *scanlineImage = reinterpret_cast<QRgb *>(image.scanLine(y));
626 const QRgb *scanlineMask = mask.isNull() ? nullptr : reinterpret_cast<const QRgb *>(mask.scanLine(y));
627 for (int x = 0; x < w ; x++){
628 if (scanlineMask && qRed(scanlineMask[x]) != 0)
629 scanlineImage[x] = 0; //mask out this pixel
630 else
631 scanlineImage[x] |= 0xff000000; // set the alpha channel to 255
632 }
633 }
634 }
635 //dispose resources created by iconinfo call
636 DeleteObject(iconinfo.hbmMask);
637 DeleteObject(iconinfo.hbmColor);
638
639 SelectObject(hdc, oldhdc); //restore state
640 DeleteObject(winBitmap);
641 DeleteDC(hdc);
642 return image;
643}
644
646{
647 return QPixmap::fromImage(QImage::fromHICON(icon));
648}
649
\inmodule QtGui
Definition qbitmap.h:16
\inmodule QtCore
\inmodule QtCore
\inmodule QtGui
Definition qimage.h:37
QSize size() const
Returns the size of the image, i.e.
int width() const
Returns the width of the image.
uchar * bits()
Returns a pointer to the first pixel data.
Definition qimage.cpp:1677
bool isNull() const
Returns true if it is a null image, otherwise returns false.
Definition qimage.cpp:1197
int height() const
Returns the height of the image.
Format
The following image formats are available in Qt.
Definition qimage.h:41
@ Format_RGB888
Definition qimage.h:55
@ Format_RGB32
Definition qimage.h:46
@ Format_Invalid
Definition qimage.h:42
@ Format_MonoLSB
Definition qimage.h:44
@ Format_RGB555
Definition qimage.h:53
@ Format_Mono
Definition qimage.h:43
@ Format_Indexed8
Definition qimage.h:45
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
@ Format_RGB16
Definition qimage.h:49
@ Format_BGR888
Definition qimage.h:71
@ Format_ARGB32
Definition qimage.h:47
@ Format_Grayscale8
Definition qimage.h:66
QImage() noexcept
Constructs a null image.
Definition qimage.cpp:766
Format format() const
Returns the format of the image.
Definition qimage.cpp:2146
const uchar * constScanLine(int) const
Returns a pointer to the pixel data at the scanline with index i.
Definition qimage.cpp:1657
void invertPixels(InvertMode=InvertRgb)
Inverts all pixel values in the image.
Definition qimage.cpp:1970
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
Definition qimage.h:124
Definition qlist.h:74
void reserve(qsizetype size)
Definition qlist.h:746
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
QImage toImage() const
Converts the pixmap to a QImage.
Definition qpixmap.cpp:412
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
Definition qpixmap.cpp:460
QBitmap mask() const
Returns true if this pixmap has an alpha channel, or has a mask, otherwise returns false.
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition qpixmap.cpp:1445
The QPlatformPixmap class provides an abstraction for native pixmaps.
ClassId classId() const
void fromImage(const QImage &image, Qt::ImageConversionFlags flags) override
\inmodule QtCore
\inmodule QtCore
Definition qsize.h:25
void qErrnoWarning(const char *msg,...)
Combined button and popup list for selecting options.
@ AutoColor
Definition qnamespace.h:477
@ color1
Definition qnamespace.h:28
Definition image.cpp:4
static QString header(const QString &name)
#define qWarning
Definition qlogging.h:162
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
GLsizei const GLfloat * v
[13]
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLuint end
GLenum src
GLenum GLuint buffer
GLint GLsizei width
GLenum target
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum GLenum const void * pixels
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
GLint GLsizei GLsizei GLenum format
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
GLuint64EXT * result
[6]
GLfloat GLfloat p
[1]
HBITMAP qt_imageToWinHBITMAP(const QImage &imageIn, int hbitmapFormat)
static void flipRgb3(uchar *p, int width, int height)
@ Indexed8ColorTableSize
static bool hasAlpha(const QImage &image)
static QImage imageFromWinHBITMAP_GetDiBits(HBITMAP bitmap, bool forceQuads, int hbitmapFormat)
static QImage qt_imageFromWinIconHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
static void initBitMapInfoHeader(int width, int height, bool topToBottom, DWORD compression, DWORD bitCount, BITMAPINFOHEADER *bih)
static QT_BEGIN_NAMESPACE Int pad4(Int v)
QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat)
static HBITMAP qt_createIconMask(QImage bm)
static RGBQUAD qRgbToRgbQuad(QRgb qrgb)
static QImage::Format format32(int hbitmapFormat)
HBitmapFormat
@ HBitmapAlpha
@ HBitmapPremultipliedAlpha
@ HBitmapNoAlpha
static QImage copyImageData(const BITMAPINFOHEADER &header, const RGBQUAD *colorTableIn, const void *data, QImage::Format format)
QPixmap qt_pixmapFromWinHICON(HICON icon)
static QImage::Format imageFromWinHBITMAP_Format(const BITMAPINFOHEADER &header, int hbitmapFormat)
QImage qt_imageFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat)
static QImage imageFromWinHBITMAP_DibSection(HBITMAP bitmap, int hbitmapFormat)
HICON qt_pixmapToWinHICON(const QPixmap &p)
HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat)
QDebug operator<<(QDebug d, const BITMAPINFOHEADER &bih)
static uchar * getDiBits(HDC hdc, HBITMAP bitmap, int width, int height, bool topToBottom=true)
static void copyImageDataCreateAlpha(const uchar *data, QImage *target)
static QRgb rgbQuadToQRgb(RGBQUAD quad)
static void initBitMapInfo(int width, int height, bool topToBottom, DWORD compression, DWORD bitCount, BITMAPINFO_T *bmi)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
QT_BEGIN_NAMESPACE typedef unsigned int QRgb
Definition qrgb.h:13
constexpr int qRed(QRgb rgb)
Definition qrgb.h:18
constexpr int qGreen(QRgb rgb)
Definition qrgb.h:21
constexpr int qBlue(QRgb rgb)
Definition qrgb.h:24
constexpr int qAlpha(QRgb rgb)
Definition qrgb.h:27
static const struct TessellationModeTab quad[]
unsigned char uchar
Definition qtypes.h:27
ptrdiff_t qsizetype
Definition qtypes.h:70
unsigned int uint
Definition qtypes.h:29
static QWindowsDirect2DPlatformPixmap * platformPixmap(QPixmap *p)
QFileInfo info(fileName)
[8]
QObject::connect nullptr
RGBQUAD bmiColors[Indexed8ColorTableSize]
BITMAPINFOHEADER bmiHeader