diff options
Diffstat (limited to 'src/gui/image/qbitmap.cpp')
-rw-r--r-- | src/gui/image/qbitmap.cpp | 70 |
1 files changed, 20 insertions, 50 deletions
diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp index 0505717fb3..315c847c91 100644 --- a/src/gui/image/qbitmap.cpp +++ b/src/gui/image/qbitmap.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** 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 <qpa/qplatformpixmap.h> @@ -46,6 +10,8 @@ #include <qpainter.h> #include <private/qguiapplication_p.h> +#include <memory> + QT_BEGIN_NAMESPACE /*! @@ -114,25 +80,31 @@ QBitmap::QBitmap() \sa clear() */ - QBitmap::QBitmap(int w, int h) : QPixmap(QSize(w, h), QPlatformPixmap::BitmapType) { } /*! + \deprecated [6.0] Use fromPixmap instead. + Constructs a bitmap with the given \a size. The pixels in the bitmap are uninitialized. \sa clear() */ - QBitmap::QBitmap(const QSize &size) : QPixmap(size, QPlatformPixmap::BitmapType) { } /*! + \internal + This dtor must stay empty until Qt 7 (was inline until 6.2). +*/ +QBitmap::~QBitmap() = default; + +/*! \fn QBitmap::clear() Clears the bitmap, setting all its bits to Qt::color0. @@ -149,7 +121,6 @@ QBitmap::QBitmap(const QSize &size) \sa QPixmap::isNull(), QImageReader::imageFormat() */ - QBitmap::QBitmap(const QString& fileName, const char *format) : QPixmap(QSize(0, 0), QPlatformPixmap::BitmapType) { @@ -158,7 +129,6 @@ QBitmap::QBitmap(const QString& fileName, const char *format) /*! \fn void QBitmap::swap(QBitmap &other) - \since 4.8 Swaps bitmap \a other with this bitmap. This operation is very fast and never fails. @@ -184,10 +154,10 @@ static QBitmap makeBitmap(QImage &&image, Qt::ImageConversionFlags flags) image.setColor(1, c0); } - QScopedPointer<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::BitmapType)); + std::unique_ptr<QPlatformPixmap> data(QGuiApplicationPrivate::platformIntegration()->createPlatformPixmap(QPlatformPixmap::BitmapType)); data->fromImageInPlace(image, flags | Qt::MonoOnly); - return QBitmap::fromPixmap(QPixmap(data.take())); + return QBitmap::fromPixmap(QPixmap(data.release())); } /*! @@ -225,7 +195,7 @@ QBitmap QBitmap::fromImage(QImage &&image, Qt::ImageConversionFlags flags) Constructs a bitmap with the given \a size, and sets the contents to the \a bits supplied. - The bitmap data has to be byte aligned and provided in in the bit + The bitmap data has to be byte aligned and provided in the bit order specified by \a monoFormat. The mono format must be either QImage::Format_Mono or QImage::Format_MonoLSB. Use QImage::Format_Mono to specify data on the XBM format. @@ -241,7 +211,7 @@ QBitmap QBitmap::fromData(const QSize &size, const uchar *bits, QImage::Format m image.setColor(0, QColor(Qt::color0).rgb()); image.setColor(1, QColor(Qt::color1).rgb()); - // Need to memcpy each line separatly since QImage is 32bit aligned and + // Need to memcpy each line separately since QImage is 32bit aligned and // this data is only byte aligned... int bytesPerLine = (size.width() + 7) / 8; for (int y = 0; y < size.height(); ++y) @@ -255,6 +225,8 @@ QBitmap QBitmap::fromData(const QSize &size, const uchar *bits, QImage::Format m If the pixmap has a depth greater than 1, the resulting bitmap will be dithered automatically. + \since 6.0 + \sa QPixmap::depth() */ @@ -277,7 +249,7 @@ QBitmap QBitmap::fromPixmap(const QPixmap &pixmap) #if QT_DEPRECATED_SINCE(6, 0) /*! - \obsolete Use fromPixmap instead. + \deprecated [6.0] Use fromPixmap instead. Constructs a bitmap that is a copy of the given \a pixmap. If the pixmap has a depth greater than 1, the resulting bitmap @@ -285,14 +257,13 @@ QBitmap QBitmap::fromPixmap(const QPixmap &pixmap) \sa QPixmap::depth(), fromImage(), fromData() */ - QBitmap::QBitmap(const QPixmap &pixmap) { *this = QBitmap::fromPixmap(pixmap); } /*! - \obsolete Use fromPixmap instead. + \deprecated [6.0] Use fromPixmap instead. \overload Assigns the given \a pixmap to this bitmap and returns a reference @@ -303,7 +274,6 @@ QBitmap::QBitmap(const QPixmap &pixmap) \sa QPixmap::depth() */ - QBitmap &QBitmap::operator=(const QPixmap &pixmap) { *this = QBitmap::fromPixmap(pixmap); |