summaryrefslogtreecommitdiffstats
path: root/src/gui/image
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/image')
-rw-r--r--src/gui/image/qbitmap.cpp1
-rw-r--r--src/gui/image/qicon.cpp145
-rw-r--r--src/gui/image/qicon_p.h39
-rw-r--r--src/gui/image/qiconengine.cpp7
-rw-r--r--src/gui/image/qiconengine.h1
-rw-r--r--src/gui/image/qiconloader.cpp32
-rw-r--r--src/gui/image/qiconloader_p.h4
-rw-r--r--src/gui/image/qimage.cpp110
-rw-r--r--src/gui/image/qimagereader.cpp18
-rw-r--r--src/gui/image/qimagewriter.cpp4
-rw-r--r--src/gui/image/qmovie.cpp13
-rw-r--r--src/gui/image/qpicture.cpp1
-rw-r--r--src/gui/image/qpixmap.cpp9
-rw-r--r--src/gui/image/qpixmap_blitter.cpp4
-rw-r--r--src/gui/image/qpixmap_raster.cpp4
-rw-r--r--src/gui/image/qpixmapcache.cpp11
16 files changed, 187 insertions, 216 deletions
diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp
index 2208cca1be..315c847c91 100644
--- a/src/gui/image/qbitmap.cpp
+++ b/src/gui/image/qbitmap.cpp
@@ -129,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.
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
index 086ac37a07..62904f957d 100644
--- a/src/gui/image/qicon.cpp
+++ b/src/gui/image/qicon.cpp
@@ -32,6 +32,33 @@
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
+// Convenience class providing a bool read() function.
+namespace {
+class ImageReader
+{
+public:
+ ImageReader(const QString &fileName) : m_reader(fileName), m_atEnd(false) { }
+
+ QByteArray format() const { return m_reader.format(); }
+
+ bool read(QImage *image)
+ {
+ if (m_atEnd)
+ return false;
+ *image = m_reader.read();
+ if (!image->size().isValid()) {
+ m_atEnd = true;
+ return false;
+ }
+ m_atEnd = !m_reader.jumpToNextImage();
+ return true;
+ }
+
+private:
+ QImageReader m_reader;
+ bool m_atEnd;
+};
+} // namespace
/*!
\enum QIcon::Mode
@@ -150,7 +177,7 @@ void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode
painter->drawPixmap(rect, px);
}
-static inline int area(const QSize &s) { return s.width() * s.height(); }
+static inline qint64 area(const QSize &s) { return qint64(s.width()) * s.height(); }
// Returns the smallest of the two that is still larger than or equal to size.
// Pixmaps at the correct scale are preferred, pixmaps at lower scale are
@@ -160,15 +187,16 @@ static inline int area(const QSize &s) { return s.width() * s.height(); }
// the 2x pixmaps then.)
static QPixmapIconEngineEntry *bestSizeScaleMatch(const QSize &size, qreal scale, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb)
{
-
+ const auto scaleA = pa->pixmap.devicePixelRatio();
+ const auto scaleB = pb->pixmap.devicePixelRatio();
// scale: we can only differentiate on scale if the scale differs
- if (pa->scale != pb->scale) {
+ if (scaleA != scaleB) {
// Score the pixmaps: 0 is an exact scale match, positive
// scores have more detail than requested, negative scores
// have less detail than requested.
- qreal ascore = pa->scale - scale;
- qreal bscore = pb->scale - scale;
+ qreal ascore = scaleA - scale;
+ qreal bscore = scaleB - scale;
// always prefer positive scores to prevent upscaling
if ((ascore < 0) != (bscore < 0))
@@ -177,18 +205,18 @@ static QPixmapIconEngineEntry *bestSizeScaleMatch(const QSize &size, qreal scale
return (qAbs(ascore) < qAbs(bscore)) ? pa : pb;
}
- int s = area(size);
+ qint64 s = area(size);
if (pa->size == QSize() && pa->pixmap.isNull()) {
pa->pixmap = QPixmap(pa->fileName);
pa->size = pa->pixmap.size();
}
- int a = area(pa->size);
+ qint64 a = area(pa->size);
if (pb->size == QSize() && pb->pixmap.isNull()) {
pb->pixmap = QPixmap(pb->fileName);
pb->size = pb->pixmap.size();
}
- int b = area(pb->size);
- int res = a;
+ qint64 b = area(pb->size);
+ qint64 res = a;
if (qMin(a,b) >= s)
res = qMin(a,b);
else
@@ -201,13 +229,14 @@ static QPixmapIconEngineEntry *bestSizeScaleMatch(const QSize &size, qreal scale
QPixmapIconEngineEntry *QPixmapIconEngine::tryMatch(const QSize &size, qreal scale, QIcon::Mode mode, QIcon::State state)
{
QPixmapIconEngineEntry *pe = nullptr;
- for (int i = 0; i < pixmaps.size(); ++i)
- if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) {
+ for (auto &entry : pixmaps) {
+ if (entry.mode == mode && entry.state == state) {
if (pe)
- pe = bestSizeScaleMatch(size, scale, &pixmaps[i], pe);
+ pe = bestSizeScaleMatch(size, scale, &entry, pe);
else
- pe = &pixmaps[i];
+ pe = &entry;
}
+ }
return pe;
}
@@ -271,41 +300,30 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St
QPixmap QPixmapIconEngine::scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale)
{
-
QPixmap pm;
QPixmapIconEngineEntry *pe = bestMatch(size, scale, mode, state, false);
if (pe)
pm = pe->pixmap;
if (pm.isNull()) {
- int idx = pixmaps.size();
- while (--idx >= 0) {
- if (pe == &pixmaps.at(idx)) {
- pixmaps.remove(idx);
- break;
- }
- }
+ removePixmapEntry(pe);
if (pixmaps.isEmpty())
return pm;
- else
- return pixmap(size, mode, state);
+ return scaledPixmap(size, mode, state, scale);
}
- QSize actualSize = pm.size();
- if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
- actualSize.scale(size, Qt::KeepAspectRatio);
-
+ const auto actualSize = adjustSize(size, pm.size());
QString key = "qt_"_L1
% HexString<quint64>(pm.cacheKey())
- % HexString<uint>(pe ? pe->mode : QIcon::Normal)
+ % HexString<quint8>(pe ? pe->mode : QIcon::Normal)
% HexString<quint64>(QGuiApplication::palette().cacheKey())
% HexString<uint>(actualSize.width())
% HexString<uint>(actualSize.height());
if (mode == QIcon::Active) {
- if (QPixmapCache::find(key % HexString<uint>(mode), &pm))
+ if (QPixmapCache::find(key % HexString<quint8>(mode), &pm))
return pm; // horray
- if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), &pm)) {
+ if (QPixmapCache::find(key % HexString<quint8>(QIcon::Normal), &pm)) {
QPixmap active = pm;
if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>(qApp))
active = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(QIcon::Active, pm);
@@ -314,7 +332,7 @@ QPixmap QPixmapIconEngine::scaledPixmap(const QSize &size, QIcon::Mode mode, QIc
}
}
- if (!QPixmapCache::find(key % HexString<uint>(mode), &pm)) {
+ if (!QPixmapCache::find(key % HexString<quint8>(mode), &pm)) {
if (pm.size() != actualSize)
pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
if (pe->mode != mode && mode != QIcon::Normal) {
@@ -324,7 +342,7 @@ QPixmap QPixmapIconEngine::scaledPixmap(const QSize &size, QIcon::Mode mode, QIc
if (!generated.isNull())
pm = generated;
}
- QPixmapCache::insert(key % HexString<uint>(mode), pm);
+ QPixmapCache::insert(key % HexString<quint8>(mode), pm);
}
return pm;
}
@@ -341,12 +359,7 @@ QSize QPixmapIconEngine::actualSize(const QSize &size, QIcon::Mode mode, QIcon::
if (QPixmapIconEngineEntry *pe = bestMatch(size, scale, mode, state, true))
actualSize = pe->size;
- if (actualSize.isNull())
- return actualSize;
-
- if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
- actualSize.scale(size, Qt::KeepAspectRatio);
- return actualSize;
+ return adjustSize(size, actualSize);
}
QList<QSize> QPixmapIconEngine::availableSizes(QIcon::Mode mode, QIcon::State state)
@@ -369,7 +382,7 @@ void QPixmapIconEngine::addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon
{
if (!pixmap.isNull()) {
QPixmapIconEngineEntry *pe = tryMatch(pixmap.size(), pixmap.devicePixelRatio(), mode, state);
- if (pe && pe->size == pixmap.size() && pe->scale == pixmap.devicePixelRatio()) {
+ if (pe && pe->size == pixmap.size() && pe->pixmap.devicePixelRatio() == pixmap.devicePixelRatio()) {
pe->pixmap = pixmap;
pe->fileName.clear();
} else {
@@ -387,41 +400,13 @@ static inline int origIcoDepth(const QImage &image)
static inline int findBySize(const QList<QImage> &images, const QSize &size)
{
- for (int i = 0; i < images.size(); ++i) {
+ for (qsizetype i = 0; i < images.size(); ++i) {
if (images.at(i).size() == size)
return i;
}
return -1;
}
-// Convenience class providing a bool read() function.
-namespace {
-class ImageReader
-{
-public:
- ImageReader(const QString &fileName) : m_reader(fileName), m_atEnd(false) {}
-
- QByteArray format() const { return m_reader.format(); }
-
- bool read(QImage *image)
- {
- if (m_atEnd)
- return false;
- *image = m_reader.read();
- if (!image->size().isValid()) {
- m_atEnd = true;
- return false;
- }
- m_atEnd = !m_reader.jumpToNextImage();
- return true;
- }
-
-private:
- QImageReader m_reader;
- bool m_atEnd;
-};
-} // namespace
-
void QPixmapIconEngine::addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state)
{
if (fileName.isEmpty())
@@ -787,7 +772,6 @@ QIcon &QIcon::operator=(const QIcon &other)
/*!
\fn void QIcon::swap(QIcon &other)
- \since 4.8
Swaps icon \a other with this icon. This operation is very
fast and never fails.
@@ -805,7 +789,6 @@ QIcon::operator QVariant() const
Returns a number that identifies the contents of this QIcon
object. Distinct QIcon objects can have the same key if
they refer to the same contents.
- \since 4.3
The cacheKey() will change when the icon is altered via
addPixmap() or addFile().
@@ -862,7 +845,9 @@ QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const
\since 6.0
Returns a pixmap with the requested \a size, \a devicePixelRatio, \a mode, and \a
- state, generating one if necessary.
+ state, generating one with the given \a mode and \a state if necessary. The pixmap
+ might be smaller than requested, but never larger, unless the device-pixel ratio
+ of the returned pixmap is larger than 1.
\sa actualSize(), paint()
*/
@@ -1134,8 +1119,6 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State
}
/*!
- \since 4.5
-
Returns a list of available icon sizes for the specified \a mode and
\a state.
*/
@@ -1147,8 +1130,6 @@ QList<QSize> QIcon::availableSizes(Mode mode, State state) const
}
/*!
- \since 4.7
-
Returns the name used to create the icon, if available.
Depending on the way the icon was created, it may have an associated
@@ -1164,8 +1145,6 @@ QString QIcon::name() const
}
/*!
- \since 4.6
-
Sets the search paths for icon themes to \a paths.
The content of \a paths should follow the theme format
@@ -1179,8 +1158,6 @@ void QIcon::setThemeSearchPaths(const QStringList &paths)
}
/*!
- \since 4.6
-
Returns the search paths for icon themes.
The default search paths will be defined by the platform.
@@ -1235,8 +1212,6 @@ void QIcon::setFallbackSearchPaths(const QStringList &paths)
}
/*!
- \since 4.6
-
Sets the current icon theme to \a name.
The theme will be will be looked up in themeSearchPaths().
@@ -1255,8 +1230,6 @@ void QIcon::setThemeName(const QString &name)
}
/*!
- \since 4.6
-
Returns the name of the current icon theme.
If not set, the current icon theme will be defined by the
@@ -1317,8 +1290,6 @@ void QIcon::setFallbackThemeName(const QString &name)
}
/*!
- \since 4.6
-
Returns the QIcon corresponding to \a name in the
\l{themeName()}{current icon theme}.
@@ -1388,8 +1359,6 @@ QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
}
/*!
- \since 4.6
-
Returns \c true if there is an icon available for \a name in the
current icon theme or any of the fallbacks, as described by
fromTheme(), otherwise returns \c false.
@@ -1836,7 +1805,6 @@ bool QIcon::isMask() const
/*!
\fn QDataStream &operator<<(QDataStream &stream, const QIcon &icon)
\relates QIcon
- \since 4.2
Writes the given \a icon to the given \a stream as a PNG
image. If the icon contains more than one image, all images will
@@ -1877,7 +1845,6 @@ QDataStream &operator<<(QDataStream &s, const QIcon &icon)
/*!
\fn QDataStream &operator>>(QDataStream &stream, QIcon &icon)
\relates QIcon
- \since 4.2
Reads an image, or a set of images, from the given \a stream into
the given \a icon.
diff --git a/src/gui/image/qicon_p.h b/src/gui/image/qicon_p.h
index c5bf120620..8050d76435 100644
--- a/src/gui/image/qicon_p.h
+++ b/src/gui/image/qicon_p.h
@@ -34,7 +34,7 @@ public:
delete engine;
}
- qreal pixmapDevicePixelRatio(qreal displayDevicePixelRatio, const QSize &requestedSize, const QSize &actualSize);
+ static qreal pixmapDevicePixelRatio(qreal displayDevicePixelRatio, const QSize &requestedSize, const QSize &actualSize);
QIconEngine *engine;
@@ -49,24 +49,22 @@ public:
struct QPixmapIconEngineEntry
{
- QPixmapIconEngineEntry():scale(1), mode(QIcon::Normal), state(QIcon::Off){}
- QPixmapIconEngineEntry(const QPixmap &pm, QIcon::Mode m = QIcon::Normal, QIcon::State s = QIcon::Off)
- :pixmap(pm), size(pm.size()), scale(pm.devicePixelRatio()), mode(m), state(s){}
- QPixmapIconEngineEntry(const QString &file, const QSize &sz = QSize(), QIcon::Mode m = QIcon::Normal, QIcon::State s = QIcon::Off)
- :fileName(file), size(sz), scale(1), mode(m), state(s){}
- QPixmapIconEngineEntry(const QString &file, const QImage &image, QIcon::Mode m = QIcon::Normal, QIcon::State s = QIcon::Off);
+ QPixmapIconEngineEntry() = default;
+ QPixmapIconEngineEntry(const QPixmap &pm, QIcon::Mode m, QIcon::State s)
+ : pixmap(pm), size(pm.size()), mode(m), state(s) {}
+ QPixmapIconEngineEntry(const QString &file, const QSize &sz, QIcon::Mode m, QIcon::State s)
+ : fileName(file), size(sz), mode(m), state(s) {}
+ QPixmapIconEngineEntry(const QString &file, const QImage &image, QIcon::Mode m, QIcon::State s);
QPixmap pixmap;
QString fileName;
QSize size;
- qreal scale;
- QIcon::Mode mode;
- QIcon::State state;
- bool isNull() const {return (fileName.isEmpty() && pixmap.isNull()); }
+ QIcon::Mode mode = QIcon::Normal;
+ QIcon::State state = QIcon::Off;
};
Q_DECLARE_TYPEINFO(QPixmapIconEngineEntry, Q_RELOCATABLE_TYPE);
inline QPixmapIconEngineEntry::QPixmapIconEngineEntry(const QString &file, const QImage &image, QIcon::Mode m, QIcon::State s)
- : fileName(file), size(image.size()), scale(image.devicePixelRatio()), mode(m), state(s)
+ : fileName(file), size(image.size()), mode(m), state(s)
{
pixmap.convertFromImage(image);
}
@@ -91,7 +89,24 @@ public:
bool read(QDataStream &in) override;
bool write(QDataStream &out) const override;
+ static inline QSize adjustSize(const QSize &expectedSize, QSize size)
+ {
+ if (!size.isNull() && (size.width() > expectedSize.width() || size.height() > expectedSize.height()))
+ size.scale(expectedSize, Qt::KeepAspectRatio);
+ return size;
+ }
+
private:
+ void removePixmapEntry(QPixmapIconEngineEntry *pe)
+ {
+ auto idx = pixmaps.size();
+ while (--idx >= 0) {
+ if (pe == &pixmaps.at(idx)) {
+ pixmaps.remove(idx);
+ return;
+ }
+ }
+ }
QPixmapIconEngineEntry *tryMatch(const QSize &size, qreal scale, QIcon::Mode mode, QIcon::State state);
QList<QPixmapIconEngineEntry> pixmaps;
diff --git a/src/gui/image/qiconengine.cpp b/src/gui/image/qiconengine.cpp
index 78273bdeb3..efcc3824ba 100644
--- a/src/gui/image/qiconengine.cpp
+++ b/src/gui/image/qiconengine.cpp
@@ -114,7 +114,6 @@ void QIconEngine::addFile(const QString &/*fileName*/, const QSize &/*size*/, QI
/*!
\enum QIconEngine::IconEngineHook
- \since 4.5
These enum values are used for virtual_hook() to allow additional
queries to icon engine without breaking binary compatibility.
@@ -224,8 +223,6 @@ bool QIconEngine::write(QDataStream &) const
}
/*!
- \since 4.5
-
Additional method to allow extending QIconEngine without
adding new virtual methods (and without breaking binary compatibility).
The actual action and format of \a data depends on \a id argument
@@ -249,8 +246,6 @@ void QIconEngine::virtual_hook(int id, void *data)
}
/*!
- \since 4.5
-
Returns sizes of all images that are contained in the engine for the
specific \a mode and \a state.
*/
@@ -260,8 +255,6 @@ QList<QSize> QIconEngine::availableSizes(QIcon::Mode /*mode*/, QIcon::State /*st
}
/*!
- \since 4.7
-
Returns the name used to create the engine, if available.
*/
QString QIconEngine::iconName()
diff --git a/src/gui/image/qiconengine.h b/src/gui/image/qiconengine.h
index 61411b0660..f5c5184608 100644
--- a/src/gui/image/qiconengine.h
+++ b/src/gui/image/qiconengine.h
@@ -18,6 +18,7 @@ public:
virtual ~QIconEngine();
virtual void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) = 0;
virtual QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
+ // ### Qt7: add qreal scale argument and remove scaledPixmap
virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
virtual void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state);
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
index 982b9a26b4..97735e4af6 100644
--- a/src/gui/image/qiconloader.cpp
+++ b/src/gui/image/qiconloader.cpp
@@ -137,6 +137,10 @@ void QIconLoader::invalidateKey()
// recreating the actual engine the next time the icon is used.
// We don't need to clear the QIcon cache itself.
m_themeKey++;
+
+ // invalidating the factory results in us looking once for
+ // a plugin that provides icon for the new themeName()
+ m_factory = std::nullopt;
}
QString QIconLoader::themeName() const
@@ -650,7 +654,18 @@ QIconEngine *QIconLoader::iconEngine(const QString &iconName) const
qCDebug(lcIconLoader) << "Resolving icon engine for icon" << iconName;
std::unique_ptr<QIconEngine> iconEngine;
- if (hasUserTheme())
+
+ if (!m_factory) {
+ qCDebug(lcIconLoader) << "Finding a plugin for theme" << themeName();
+ // try to find a plugin that supports the current theme
+ const int factoryIndex = qt_iconEngineFactoryLoader()->indexOf(themeName());
+ if (factoryIndex >= 0)
+ m_factory = qobject_cast<QIconEnginePlugin *>(qt_iconEngineFactoryLoader()->instance(factoryIndex));
+ }
+ if (m_factory && *m_factory)
+ iconEngine.reset(m_factory.value()->create(iconName));
+
+ if (hasUserTheme() && (!iconEngine || iconEngine->isNull()))
iconEngine.reset(new QIconLoaderEngine(iconName));
if (!iconEngine || iconEngine->isNull()) {
qCDebug(lcIconLoader) << "Icon is not available from theme or fallback theme.";
@@ -894,18 +909,15 @@ QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State st
if (basePixmap.isNull())
basePixmap.load(filename);
- QSize actualSize = basePixmap.size();
// If the size of the best match we have (basePixmap) is larger than the
// requested size, we downscale it to match.
- if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
- actualSize.scale(size, Qt::KeepAspectRatio);
-
+ const auto actualSize = QPixmapIconEngine::adjustSize(size, basePixmap.size());
QString key = "$qt_theme_"_L1
- % HexString<qint64>(basePixmap.cacheKey())
- % HexString<int>(mode)
- % HexString<qint64>(QGuiApplication::palette().cacheKey())
- % HexString<int>(actualSize.width())
- % HexString<int>(actualSize.height());
+ % HexString<quint64>(basePixmap.cacheKey())
+ % HexString<quint8>(mode)
+ % HexString<quint64>(QGuiApplication::palette().cacheKey())
+ % HexString<uint>(actualSize.width())
+ % HexString<uint>(actualSize.height());
QPixmap cachedPixmap;
if (QPixmapCache::find(key, &cachedPixmap)) {
diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h
index 3cfa9381d1..4a8079a3e9 100644
--- a/src/gui/image/qiconloader_p.h
+++ b/src/gui/image/qiconloader_p.h
@@ -30,6 +30,7 @@
#include <vector>
#include <memory>
+#include <optional>
QT_BEGIN_NAMESPACE
@@ -161,6 +162,8 @@ public:
QList<QSharedPointer<QIconCacheGtkReader>> m_gtkCaches;
};
+class QIconEnginePlugin;
+
class Q_GUI_EXPORT QIconLoader
{
public:
@@ -195,6 +198,7 @@ private:
QThemeIconInfo lookupFallbackIcon(const QString &iconName) const;
uint m_themeKey;
+ mutable std::optional<QIconEnginePlugin *> m_factory;
bool m_supportsSvg;
bool m_initialized;
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index a23bdfcadd..5a2af0dbb0 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -713,39 +713,60 @@ bool QImageData::checkForAlphaPixels() const
The unused bits are always zero.
\value Format_ARGB4444_Premultiplied The image is stored using a
premultiplied 16-bit ARGB format (4-4-4-4).
- \value Format_RGBX8888 The image is stored using a 32-bit byte-ordered RGB(x) format (8-8-8-8).
- This is the same as the Format_RGBA8888 except alpha must always be 255. (added in Qt 5.2)
- \value Format_RGBA8888 The image is stored using a 32-bit byte-ordered RGBA format (8-8-8-8).
+ \value [since 5.2]
+ Format_RGBX8888 The image is stored using a 32-bit byte-ordered RGB(x) format (8-8-8-8).
+ This is the same as the Format_RGBA8888 except alpha must always be 255.
+ \value [since 5.2]
+ Format_RGBA8888 The image is stored using a 32-bit byte-ordered RGBA format (8-8-8-8).
Unlike ARGB32 this is a byte-ordered format, which means the 32bit
encoding differs between big endian and little endian architectures,
being respectively (0xRRGGBBAA) and (0xAABBGGRR). The order of the colors
- is the same on any architecture if read as bytes 0xRR,0xGG,0xBB,0xAA. (added in Qt 5.2)
- \value Format_RGBA8888_Premultiplied The image is stored using a
- premultiplied 32-bit byte-ordered RGBA format (8-8-8-8). (added in Qt 5.2)
- \value Format_BGR30 The image is stored using a 32-bit BGR format (x-10-10-10). (added in Qt 5.4)
- \value Format_A2BGR30_Premultiplied The image is stored using a 32-bit premultiplied ABGR format (2-10-10-10). (added in Qt 5.4)
- \value Format_RGB30 The image is stored using a 32-bit RGB format (x-10-10-10). (added in Qt 5.4)
- \value Format_A2RGB30_Premultiplied The image is stored using a 32-bit premultiplied ARGB format (2-10-10-10). (added in Qt 5.4)
- \value Format_Alpha8 The image is stored using an 8-bit alpha only format. (added in Qt 5.5)
- \value Format_Grayscale8 The image is stored using an 8-bit grayscale format. (added in Qt 5.5)
- \value Format_Grayscale16 The image is stored using an 16-bit grayscale format. (added in Qt 5.13)
- \value Format_RGBX64 The image is stored using a 64-bit halfword-ordered RGB(x) format (16-16-16-16).
- This is the same as the Format_RGBA64 except alpha must always be 65535. (added in Qt 5.12)
- \value Format_RGBA64 The image is stored using a 64-bit halfword-ordered RGBA format (16-16-16-16). (added in Qt 5.12)
- \value Format_RGBA64_Premultiplied The image is stored using a premultiplied 64-bit halfword-ordered
- RGBA format (16-16-16-16). (added in Qt 5.12)
- \value Format_BGR888 The image is stored using a 24-bit BGR format. (added in Qt 5.14)
- \value Format_RGBX16FPx4 The image is stored using a 4 16-bit halfword floating point RGBx format (16FP-16FP-16FP-16FP).
- This is the same as the Format_RGBA16FPx4 except alpha must always be 1.0. (added in Qt 6.2)
- \value Format_RGBA16FPx4 The image is stored using a 4 16-bit halfword floating point RGBA format (16FP-16FP-16FP-16FP). (added in Qt 6.2)
- \value Format_RGBA16FPx4_Premultiplied The image is stored using a premultiplied 4 16-bit halfword floating point
- RGBA format (16FP-16FP-16FP-16FP). (added in Qt 6.2)
- \value Format_RGBX32FPx4 The image is stored using a 4 32-bit floating point RGBx format (32FP-32FP-32FP-32FP).
- This is the same as the Format_RGBA32FPx4 except alpha must always be 1.0. (added in Qt 6.2)
- \value Format_RGBA32FPx4 The image is stored using a 4 32-bit floating point RGBA format (32FP-32FP-32FP-32FP). (added in Qt 6.2)
- \value Format_RGBA32FPx4_Premultiplied The image is stored using a premultiplied 4 32-bit floating point
- RGBA format (32FP-32FP-32FP-32FP). (added in Qt 6.2)
- \value Format_CMYK8888 The image is stored using a 32-bit byte-ordered CMYK format. (added in Qt 6.8)
+ is the same on any architecture if read as bytes 0xRR,0xGG,0xBB,0xAA.
+ \value [since 5.2]
+ Format_RGBA8888_Premultiplied The image is stored using a
+ premultiplied 32-bit byte-ordered RGBA format (8-8-8-8).
+ \value [since 5.4]
+ Format_BGR30 The image is stored using a 32-bit BGR format (x-10-10-10).
+ \value [since 5.4]
+ Format_A2BGR30_Premultiplied The image is stored using a 32-bit premultiplied ABGR format (2-10-10-10).
+ \value [since 5.4]
+ Format_RGB30 The image is stored using a 32-bit RGB format (x-10-10-10).
+ \value [since 5.4]
+ Format_A2RGB30_Premultiplied The image is stored using a 32-bit premultiplied ARGB format (2-10-10-10).
+ \value [since 5.5]
+ Format_Alpha8 The image is stored using an 8-bit alpha only format.
+ \value [since 5.5]
+ Format_Grayscale8 The image is stored using an 8-bit grayscale format.
+ \value [since 5.13]
+ Format_Grayscale16 The image is stored using an 16-bit grayscale format.
+ \value [since 5.12]
+ Format_RGBX64 The image is stored using a 64-bit halfword-ordered RGB(x) format (16-16-16-16).
+ This is the same as the Format_RGBA64 except alpha must always be 65535.
+ \value [since 5.12]
+ Format_RGBA64 The image is stored using a 64-bit halfword-ordered RGBA format (16-16-16-16).
+ \value [since 5.12]
+ Format_RGBA64_Premultiplied The image is stored using a premultiplied 64-bit halfword-ordered
+ RGBA format (16-16-16-16).
+ \value [since 5.14]
+ Format_BGR888 The image is stored using a 24-bit BGR format.
+ \value [since 6.2]
+ Format_RGBX16FPx4 The image is stored using a four 16-bit halfword floating point RGBx format (16FP-16FP-16FP-16FP).
+ This is the same as the Format_RGBA16FPx4 except alpha must always be 1.0.
+ \value [since 6.2]
+ Format_RGBA16FPx4 The image is stored using a four 16-bit halfword floating point RGBA format (16FP-16FP-16FP-16FP).
+ \value [since 6.2]
+ Format_RGBA16FPx4_Premultiplied The image is stored using a premultiplied four 16-bit halfword floating point
+ RGBA format (16FP-16FP-16FP-16FP).
+ \value [since 6.2]
+ Format_RGBX32FPx4 The image is stored using a four 32-bit floating point RGBx format (32FP-32FP-32FP-32FP).
+ This is the same as the Format_RGBA32FPx4 except alpha must always be 1.0.
+ \value [since 6.2]
+ Format_RGBA32FPx4 The image is stored using a four 32-bit floating point RGBA format (32FP-32FP-32FP-32FP).
+ \value [since 6.2]
+ Format_RGBA32FPx4_Premultiplied The image is stored using a premultiplied four 32-bit floating point
+ RGBA format (32FP-32FP-32FP-32FP).
+ \value [since 6.8]
+ Format_CMYK8888 The image is stored using a 32-bit byte-ordered CMYK format.
\note Drawing into a QImage with format QImage::Format_Indexed8 or QImage::Format_CMYK8888 is not
supported.
@@ -1072,7 +1093,6 @@ QImage &QImage::operator=(const QImage &image)
/*!
\fn void QImage::swap(QImage &other)
- \since 4.8
Swaps image \a other with this image. This operation is very
fast and never fails.
@@ -1151,9 +1171,10 @@ static void copyPhysicalMetadata(QImageData *dst, const QImageData *src)
static void copyMetadata(QImageData *dst, const QImageData *src)
{
- // Doesn't copy colortable and alpha_clut, or offset.
+ // Doesn't copy colortable and alpha_clut.
copyPhysicalMetadata(dst, src);
dst->text = src->text;
+ dst->offset = src->offset;
dst->colorSpace = src->colorSpace;
}
@@ -1218,7 +1239,6 @@ QImage Q_TRACE_INSTRUMENT(qtgui) QImage::copy(const QRect& r) const
} else
memcpy(image.bits(), bits(), d->nbytes);
image.d->colortable = d->colortable;
- image.d->offset = d->offset;
image.d->has_alpha_clut = d->has_alpha_clut;
copyMetadata(image.d, d);
return image;
@@ -1307,7 +1327,6 @@ QImage Q_TRACE_INSTRUMENT(qtgui) QImage::copy(const QRect& r) const
}
copyMetadata(image.d, d);
- image.d->offset = offset();
image.d->has_alpha_clut = d->has_alpha_clut;
return image;
}
@@ -1392,7 +1411,6 @@ int QImage::depth() const
}
/*!
- \since 4.6
\fn int QImage::colorCount() const
Returns the size of the color table for the image.
@@ -1656,7 +1674,6 @@ const uchar *QImage::scanLine(int i) const
shared pixel data, because the returned data is const.
\sa scanLine(), constBits()
- \since 4.7
*/
const uchar *QImage::constScanLine(int i) const
{
@@ -1712,7 +1729,6 @@ const uchar *QImage::bits() const
shared pixel data, because the returned data is const.
\sa bits(), constScanLine()
- \since 4.7
*/
const uchar *QImage::constBits() const
{
@@ -1819,7 +1835,6 @@ void QImage::fill(uint pixel)
/*!
\fn void QImage::fill(Qt::GlobalColor color)
\overload
- \since 4.8
Fills the image with the given \a color, described as a standard global
color.
@@ -1845,8 +1860,6 @@ void QImage::fill(Qt::GlobalColor color)
If the depth of the image is 8, the image will be filled with the
index corresponding the \a color in the color table if present; it
will otherwise be filled with 0.
-
- \since 4.8
*/
void QImage::fill(const QColor &color)
@@ -2103,7 +2116,6 @@ void QImage::invertPixels(InvertMode mode)
#endif
/*!
- \since 4.6
Resizes the color table to contain \a colorCount entries.
If the color table is expanded, all the extra colors will be set to
@@ -2207,7 +2219,6 @@ QImage QImage::convertToFormat_helper(Format format, Qt::ImageConversionFlags fl
QIMAGE_SANITYCHECK_MEMORY(image);
- image.d->offset = offset();
copyMetadata(image.d, d);
converter(image.d, d, flags);
@@ -4312,6 +4323,12 @@ int QImage::metric(PaintDeviceMetric metric) const
return d->devicePixelRatio * QPaintDevice::devicePixelRatioFScale();
break;
+ case PdmDevicePixelRatioF_EncodedA:
+ Q_FALLTHROUGH();
+ case PdmDevicePixelRatioF_EncodedB:
+ return QPaintDevice::encodeMetricF(metric, d->devicePixelRatio);
+ break;
+
default:
qWarning("QImage::metric(): Unhandled metric type %d", metric);
break;
@@ -4588,7 +4605,6 @@ bool QImage::hasAlphaChannel() const
}
/*!
- \since 4.7
Returns the number of bit planes in the image.
The number of bit planes is the number of bits of color and
@@ -4683,6 +4699,8 @@ QImage QImage::smoothScaled(int w, int h) const
src.convertTo(QImage::Format_RGBA32FPx4_Premultiplied);
break;
#endif
+ case QImage::Format_CMYK8888:
+ break;
default:
if (src.hasAlphaChannel())
src.convertTo(QImage::Format_ARGB32_Premultiplied);
@@ -4825,6 +4843,9 @@ QImage Q_TRACE_INSTRUMENT(qtgui) QImage::transformed(const QTransform &matrix, Q
// with scaling smoothly more than 2x down.
if (hd * 2 < hs || wd * 2 < ws)
nonpaintable_scale_xform = true;
+ // We cannot paint on a CMYK image, so don't try to do so
+ if (format() == QImage::Format_CMYK8888)
+ nonpaintable_scale_xform = true;
} else {
if (mat.type() <= QTransform::TxRotate && mat.m11() == 0 && mat.m22() == 0) {
if (mat.m12() == 1. && mat.m21() == -1.)
@@ -4856,6 +4877,7 @@ QImage Q_TRACE_INSTRUMENT(qtgui) QImage::transformed(const QTransform &matrix, Q
case QImage::Format_RGBX64:
case QImage::Format_RGBA64_Premultiplied:
#endif
+ case QImage::Format_CMYK8888:
// Use smoothScaled for scaling when we can do so without conversion.
if (mat.m11() > 0.0F && mat.m22() > 0.0F)
return smoothScaled(wd, hd);
@@ -4926,7 +4948,7 @@ QImage Q_TRACE_INSTRUMENT(qtgui) QImage::transformed(const QTransform &matrix, Q
} else
memset(dImage.bits(), 0x00, dImage.d->nbytes);
- if (target_format >= QImage::Format_RGB32) {
+ if (target_format >= QImage::Format_RGB32 && target_format != QImage::Format_CMYK8888) {
// Prevent QPainter from applying devicePixelRatio corrections
QImage sImage = (devicePixelRatio() != 1) ? QImage(constBits(), width(), height(), format()) : *this;
if (sImage.d != d
diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp
index 9366e9cbb1..1f85fef3bd 100644
--- a/src/gui/image/qimagereader.cpp
+++ b/src/gui/image/qimagereader.cpp
@@ -800,8 +800,6 @@ QString QImageReader::fileName() const
}
/*!
- \since 4.2
-
Sets the quality setting of the image format to \a quality.
Some image formats, in particular lossy ones, entail a tradeoff between a)
@@ -825,8 +823,6 @@ void QImageReader::setQuality(int quality)
}
/*!
- \since 4.2
-
Returns the quality setting of the image format.
\sa setQuality()
@@ -856,8 +852,6 @@ QSize QImageReader::size() const
}
/*!
- \since 4.5
-
Returns the format of the image, without actually reading the image
contents. The format describes the image format \l QImageReader::read()
returns, not the format of the actual image.
@@ -876,8 +870,6 @@ QImage::Format QImageReader::imageFormat() const
}
/*!
- \since 4.1
-
Returns the text keys for this image. You can use
these keys with text() to list the image text for
a certain key.
@@ -894,8 +886,6 @@ QStringList QImageReader::textKeys() const
}
/*!
- \since 4.1
-
Returns the image text associated with \a key.
Support for this option is implemented through
@@ -985,8 +975,6 @@ QRect QImageReader::scaledClipRect() const
}
/*!
- \since 4.1
-
Sets the background color to \a color.
Image formats that support this operation are expected to
initialize the background to \a color before reading an image.
@@ -1000,8 +988,6 @@ void QImageReader::setBackgroundColor(const QColor &color)
}
/*!
- \since 4.1
-
Returns the background color that's used when reading an image.
If the image format does not support setting the background color
an invalid color is returned.
@@ -1016,8 +1002,6 @@ QColor QImageReader::backgroundColor() const
}
/*!
- \since 4.1
-
Returns \c true if the image format supports animation;
otherwise, false is returned.
@@ -1432,8 +1416,6 @@ QString QImageReader::errorString() const
}
/*!
- \since 4.2
-
Returns \c true if the reader supports \a option; otherwise returns
false.
diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp
index d2176e4189..0fcc783e6d 100644
--- a/src/gui/image/qimagewriter.cpp
+++ b/src/gui/image/qimagewriter.cpp
@@ -588,8 +588,6 @@ QImageIOHandler::Transformations QImageWriter::transformation() const
}
/*!
- \since 4.1
-
Sets the image text associated with the key \a key to
\a text. This is useful for storing copyright information
or other information about the image. Example:
@@ -710,8 +708,6 @@ QString QImageWriter::errorString() const
}
/*!
- \since 4.2
-
Returns \c true if the writer supports \a option; otherwise returns
false.
diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp
index 435f1dced9..8fd62c2361 100644
--- a/src/gui/image/qmovie.cpp
+++ b/src/gui/image/qmovie.cpp
@@ -103,7 +103,6 @@
*/
/*! \fn void QMovie::frameChanged(int frameNumber)
- \since 4.1
This signal is emitted when the frame number has changed to
\a frameNumber. You can call currentImage() or currentPixmap() to get a
@@ -319,7 +318,7 @@ QFrameInfo QMoviePrivate::infoForFrame(int frameNumber)
// For an animated image format, QImageIOHandler::nextImageDelay() should
// provide the time to wait until showing the next frame; but multi-frame
// formats are not expected to provide this value, so use 1000 ms by default.
- const int nextFrameDelay = supportsAnimation ? reader->nextImageDelay() : 1000;
+ const auto nextFrameDelay = [&]() { return supportsAnimation ? reader->nextImageDelay() : 1000; };
if (cacheMode == QMovie::CacheNone) {
if (frameNumber != currentFrameNumber+1) {
@@ -363,7 +362,7 @@ QFrameInfo QMoviePrivate::infoForFrame(int frameNumber)
}
if (frameNumber > greatestFrameNumber)
greatestFrameNumber = frameNumber;
- return QFrameInfo(QPixmap::fromImage(std::move(anImage)), nextFrameDelay);
+ return QFrameInfo(QPixmap::fromImage(std::move(anImage)), nextFrameDelay());
} else if (frameNumber != 0) {
// We've read all frames now. Return an end marker
haveReadAll = true;
@@ -391,7 +390,7 @@ QFrameInfo QMoviePrivate::infoForFrame(int frameNumber)
return QFrameInfo(); // Invalid
}
greatestFrameNumber = i;
- QFrameInfo info(QPixmap::fromImage(std::move(anImage)), nextFrameDelay);
+ QFrameInfo info(QPixmap::fromImage(std::move(anImage)), nextFrameDelay());
// Cache it!
frameMap.insert(i, info);
if (i == frameNumber) {
@@ -973,8 +972,6 @@ void QMovie::stop()
}
/*!
- \since 4.1
-
Returns the scaled size of frames.
\sa QImageReader::scaledSize()
@@ -986,8 +983,6 @@ QSize QMovie::scaledSize()
}
/*!
- \since 4.1
-
Sets the scaled frame size to \a size.
\sa QImageReader::setScaledSize()
@@ -999,8 +994,6 @@ void QMovie::setScaledSize(const QSize &size)
}
/*!
- \since 4.1
-
Returns the list of image formats supported by QMovie.
\sa QImageReader::supportedImageFormats()
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index da8c5ef1e5..0bc21a3e9f 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -925,7 +925,6 @@ QPicture& QPicture::operator=(const QPicture &p)
/*!
\fn void QPicture::swap(QPicture &other)
- \since 4.8
Swaps picture \a other with this picture. This operation is very
fast and never fails.
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 89b8d5303b..afef16f867 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -289,7 +289,6 @@ QPixmap QPixmap::copy(const QRect &rect) const
/*!
\fn QPixmap::scroll(int dx, int dy, int x, int y, int width, int height, QRegion *exposed)
- \since 4.6
This convenience function is equivalent to calling QPixmap::scroll(\a dx,
\a dy, QRect(\a x, \a y, \a width, \a height), \a exposed).
@@ -298,8 +297,6 @@ QPixmap QPixmap::copy(const QRect &rect) const
*/
/*!
- \since 4.6
-
Scrolls the area \a rect of this pixmap by (\a dx, \a dy). The exposed
region is left unchanged. You can optionally pass a pointer to an empty
QRegion to get the region that is \a exposed by the scroll operation.
@@ -371,7 +368,6 @@ QPixmap &QPixmap::operator=(const QPixmap &pixmap)
/*!
\fn void QPixmap::swap(QPixmap &other)
- \since 4.8
Swaps pixmap \a other with this pixmap. This operation is very
fast and never fails.
@@ -970,12 +966,7 @@ bool QPixmap::isDetached() const
Passing 0 for \a flags sets all the default options. Returns \c true
if the result is that this pixmap is not null.
- Note: this function was part of Qt 3 support in Qt 4.6 and earlier.
- It has been promoted to official API status in 4.7 to support updating
- the pixmap's image without creating a new QPixmap as fromImage() would.
-
\sa fromImage()
- \since 4.7
*/
bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags)
{
diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp
index 41563bf380..925ac37be4 100644
--- a/src/gui/image/qpixmap_blitter.cpp
+++ b/src/gui/image/qpixmap_blitter.cpp
@@ -88,6 +88,10 @@ int QBlittablePlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) con
return devicePixelRatio();
case QPaintDevice::PdmDevicePixelRatioScaled:
return devicePixelRatio() * QPaintDevice::devicePixelRatioFScale();
+ case QPaintDevice::PdmDevicePixelRatioF_EncodedA:
+ Q_FALLTHROUGH();
+ case QPaintDevice::PdmDevicePixelRatioF_EncodedB:
+ return QPaintDevice::encodeMetricF(metric, devicePixelRatio());
default:
qWarning("QRasterPlatformPixmap::metric(): Unhandled metric type %d", metric);
break;
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index 6e10bdd562..a261bb7b5c 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -253,6 +253,10 @@ int QRasterPlatformPixmap::metric(QPaintDevice::PaintDeviceMetric metric) const
return image.devicePixelRatio();
case QPaintDevice::PdmDevicePixelRatioScaled:
return image.devicePixelRatio() * QPaintDevice::devicePixelRatioFScale();
+ case QPaintDevice::PdmDevicePixelRatioF_EncodedA:
+ Q_FALLTHROUGH();
+ case QPaintDevice::PdmDevicePixelRatioF_EncodedB:
+ return QPaintDevice::encodeMetricF(metric, image.devicePixelRatio());
default:
qWarning("QRasterPlatformPixmap::metric(): Unhandled metric type %d", metric);
diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp
index 45c9743f93..b0db1f48cb 100644
--- a/src/gui/image/qpixmapcache.cpp
+++ b/src/gui/image/qpixmapcache.cpp
@@ -81,7 +81,6 @@ static inline bool qt_pixmapcache_thread_test()
\brief The QPixmapCache::Key class can be used for efficient access
to the QPixmapCache.
\inmodule QtGui
- \since 4.6
Use QPixmapCache::insert() to receive an instance of Key generated
by the pixmap cache. You can store the key in your own objects for
@@ -421,8 +420,6 @@ QPixmapCacheEntry::~QPixmapCacheEntry()
If the pixmap is found, the function sets \a pixmap to that pixmap and
returns \c true; otherwise it leaves \a pixmap alone and returns \c false.
- \since 4.6
-
Example:
\snippet code/src_gui_image_qpixmapcache.cpp 1
*/
@@ -443,8 +440,6 @@ bool QPixmapCache::find(const QString &key, QPixmap *pixmap)
returns \c true; otherwise it leaves \a pixmap alone and returns \c false. If
the pixmap is not found, it means that the \a key is no longer valid,
so it will be released for the next insertion.
-
- \since 4.6
*/
bool QPixmapCache::find(const Key &key, QPixmap *pixmap)
{
@@ -498,8 +493,6 @@ bool QPixmapCache::insert(const QString &key, const QPixmap &pixmap)
deleted when more space is needed.
\sa setCacheLimit(), replace()
-
- \since 4.6
*/
QPixmapCache::Key QPixmapCache::insert(const QPixmap &pixmap)
{
@@ -523,8 +516,6 @@ QPixmapCache::Key QPixmapCache::insert(const QPixmap &pixmap)
the cache by this function.
\sa setCacheLimit(), insert()
-
- \since 4.6
*/
#endif // QT_DEPRECATED_SINCE(6, 6)
@@ -571,8 +562,6 @@ void QPixmapCache::remove(const QString &key)
/*!
Removes the pixmap associated with \a key from the cache and releases
the key for a future insertion.
-
- \since 4.6
*/
void QPixmapCache::remove(const Key &key)
{