QtGui: Add a header declaring the Windows image conversion functions

The declarations with default parameters cause
conflicts in CMake Unity (Jumbo) builds.

Task-number: QTBUG-109394
Change-Id: Icf48193498d70dfacadf1b2499cb3359169f72c0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 65cda1f06aa24d9b75e81b37a5c23dcedbc53b92)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Friedemann Kleint 2023-02-08 12:26:11 +01:00 committed by Qt Cherry-pick Bot
parent 2670f7dcf1
commit 83b2d0292f
6 changed files with 51 additions and 15 deletions

View File

@ -393,7 +393,7 @@ qt_internal_extend_target(Gui CONDITION QT_FEATURE_animation
qt_internal_extend_target(Gui CONDITION WIN32
SOURCES
image/qpixmap_win.cpp
image/qpixmap_win.cpp image/qpixmap_win_p.h
kernel/qwindowdefs_win.h
platform/windows/qwindowsguieventdispatcher.cpp platform/windows/qwindowsguieventdispatcher_p.h
platform/windows/qwindowsmimeconverter.h platform/windows/qwindowsmimeconverter.cpp

View File

@ -3,6 +3,7 @@
#include "qbitmap.h"
#include "qpixmap.h"
#include <private/qpixmap_win_p.h>
#include <qpa/qplatformpixmap.h>
#include "qpixmap_raster_p.h"
@ -206,7 +207,7 @@ static HBITMAP qt_createIconMask(QImage bm)
return hbm;
}
Q_GUI_EXPORT HBITMAP qt_createIconMask(const QBitmap &bitmap)
HBITMAP qt_createIconMask(const QBitmap &bitmap)
{
return qt_createIconMask(bitmap.toImage().convertToFormat(QImage::Format_Mono));
}
@ -224,7 +225,7 @@ static inline QImage::Format format32(int hbitmapFormat)
return QImage::Format_ARGB32_Premultiplied;
}
Q_GUI_EXPORT HBITMAP qt_imageToWinHBITMAP(const QImage &imageIn, int hbitmapFormat = 0)
HBITMAP qt_imageToWinHBITMAP(const QImage &imageIn, int hbitmapFormat)
{
if (imageIn.isNull())
return nullptr;
@ -350,7 +351,7 @@ HBITMAP QImage::toHBITMAP() const
return qt_imageToWinHBITMAP(*this);
}
Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0)
HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat)
{
if (p.isNull())
return nullptr;
@ -449,7 +450,7 @@ static QImage imageFromWinHBITMAP_GetDiBits(HBITMAP bitmap, bool forceQuads, int
return copyImageData(info.bmiHeader, bmiColorTable256.bmiColors, data.data(), imageFormat);
}
Q_GUI_EXPORT QImage qt_imageFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0)
QImage qt_imageFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat)
{
QImage result = imageFromWinHBITMAP_DibSection(bitmap, hbitmapFormat);
if (result.isNull())
@ -481,7 +482,7 @@ QImage QImage::fromHBITMAP(HBITMAP hbitmap)
return qt_imageFromWinHBITMAP(hbitmap);
}
Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0)
QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat)
{
return QPixmap::fromImage(imageFromWinHBITMAP_GetDiBits(bitmap, /* forceQuads */ true, hbitmapFormat));
}
@ -532,7 +533,7 @@ HICON QImage::toHICON(const QImage &mask) const
return hIcon;
}
Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &p)
HICON qt_pixmapToWinHICON(const QPixmap &p)
{
QImage mask;
QBitmap maskBitmap = p.mask();
@ -541,7 +542,7 @@ Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &p)
return p.toImage().toHICON(mask);
}
Q_GUI_EXPORT QImage qt_imageFromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
QImage qt_imageFromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h)
{
QImage image(w, h, QImage::Format_ARGB32_Premultiplied);
if (image.isNull())
@ -641,7 +642,7 @@ QImage QImage::fromHICON(HICON icon)
return image;
}
Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon)
QPixmap qt_pixmapFromWinHICON(HICON icon)
{
return QPixmap::fromImage(QImage::fromHICON(icon));
}

View File

@ -0,0 +1,38 @@
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPIXMAP_WIN_P_H
#define QPIXMAP_WIN_P_H
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#include <QtGui/private/qtguiglobal_p.h>
#include <QtCore/qt_windows.h>
QT_BEGIN_NAMESPACE
class QBitmap;
class QImage;
class QPixmap;
Q_GUI_EXPORT HBITMAP qt_createIconMask(const QBitmap &bitmap);
Q_GUI_EXPORT HBITMAP qt_imageToWinHBITMAP(const QImage &imageIn, int hbitmapFormat = 0);
Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0);
Q_GUI_EXPORT QImage qt_imageFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0);
Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0);
Q_GUI_EXPORT HICON qt_pixmapToWinHICON(const QPixmap &p);
Q_GUI_EXPORT QImage qt_imageFromWinHBITMAP(HDC hdc, HBITMAP bitmap, int w, int h);
Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon);
QT_END_NAMESPACE
#endif // QPIXMAP_WIN_P_H

View File

@ -14,6 +14,7 @@
#include <QtGui/qscreen.h>
#include <QtGui/private/qguiapplication_p.h> // getPixmapCursor()
#include <QtGui/private/qhighdpiscaling_p.h>
#include <QtGui/private/qpixmap_win_p.h>
#include <QtCore/private/qwinregistry_p.h>
#include <QtCore/qdebug.h>
@ -29,9 +30,6 @@ static bool initResources()
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0);
Q_GUI_EXPORT HBITMAP qt_createIconMask(const QBitmap &bitmap);
/*!
\class QWindowsCursorCacheKey
\brief Cache key for storing values in a QHash with a QCursor as key.

View File

@ -6,6 +6,7 @@
#include "qwindowswindow.h"
#include <QtGui/qwindow.h>
#include <QtGui/private/qpixmap_win_p.h>
#include <QtCore/qdebug.h>
#include <QtCore/qvariant.h>
#include <QtCore/qmetaobject.h>
@ -229,8 +230,6 @@ void QWindowsMenuItem::setIcon(const QIcon &icon)
updateBitmap();
}
Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0);
void QWindowsMenuItem::updateBitmap()
{
freeBitmap();

View File

@ -30,10 +30,10 @@
#include <QtCore/QMetaType>
#include <QtCore/qt_windows.h>
#include <QtGui/qpagelayout.h>
#include <QtGui/private/qpixmap_win_p.h>
QT_BEGIN_NAMESPACE
Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0);
extern QPainterPath qt_regionToPath(const QRegion &region);
extern QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits);