diff options
Diffstat (limited to 'src/gui/image/qpixmap_win.cpp')
-rw-r--r-- | src/gui/image/qpixmap_win.cpp | 62 |
1 files changed, 14 insertions, 48 deletions
diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp index aae4a1cbf4..fc601bccfc 100644 --- a/src/gui/image/qpixmap_win.cpp +++ b/src/gui/image/qpixmap_win.cpp @@ -1,44 +1,9 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 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 #include "qbitmap.h" #include "qpixmap.h" +#include <private/qpixmap_win_p.h> #include <qpa/qplatformpixmap.h> #include "qpixmap_raster_p.h" @@ -199,7 +164,7 @@ static QImage copyImageData(const BITMAPINFOHEADER &header, const RGBQUAD *color Q_ASSERT(DWORD(image.sizeInBytes()) == header.biSizeImage); memcpy(image.bits(), data, header.biSizeImage); if (format == QImage::Format_RGB888) - image = image.rgbSwapped(); + image = std::move(image).rgbSwapped(); break; default: Q_UNREACHABLE(); @@ -242,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)); } @@ -260,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; @@ -340,6 +305,7 @@ Q_GUI_EXPORT HBITMAP qt_imageToWinHBITMAP(const QImage &imageIn, int hbitmapForm return nullptr; } if (!pixels) { + DeleteObject(bitmap); qErrnoWarning("%s, did not allocate pixel data", __FUNCTION__); return nullptr; } @@ -359,7 +325,7 @@ Q_GUI_EXPORT HBITMAP qt_imageToWinHBITMAP(const QImage &imageIn, int hbitmapForm It is the caller's responsibility to free the \c HBITMAP data after use. - For usage with with standard GDI calls, such as \c BitBlt(), the image + For usage with standard GDI calls, such as \c BitBlt(), the image should have the format QImage::Format_RGB32. When using the resulting HBITMAP for the \c AlphaBlend() GDI function, @@ -386,7 +352,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; @@ -485,7 +451,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()) @@ -517,7 +483,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)); } @@ -568,7 +534,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(); @@ -577,7 +543,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()) @@ -677,7 +643,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)); } |