diff options
Diffstat (limited to 'src/gui/image/qpixmap.cpp')
-rw-r--r-- | src/gui/image/qpixmap.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index c6d8d19bb1..88ce48f0e8 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtGui module of the Qt Toolkit. @@ -648,14 +648,14 @@ void QPixmap::setMask(const QBitmap &mask) /*! Returns the device pixel ratio for the pixmap. This is the - ratio between pixmap pixels and device-independent pixels. + ratio between \e{device pixels} and \e{device independent pixels}. Use this function when calculating layout geometry based on the pixmap size: QSize layoutSize = image.size() / image.devicePixelRatio() The default value is 1.0. - \sa setDevicePixelRatio() + \sa setDevicePixelRatio(), QImageReader */ qreal QPixmap::devicePixelRatio() const { @@ -680,7 +680,8 @@ qreal QPixmap::devicePixelRatio() const pixmap size will take the ratio into account: QSize layoutSize = pixmap.size() / pixmap.devicePixelRatio() The net effect of this is that the pixmap is displayed as - high-dpi pixmap rather than a large pixmap. + high-DPI pixmap rather than a large pixmap + (see \l{Drawing High Resolution Versions of Pixmaps and Images}). \sa devicePixelRatio() */ @@ -1511,7 +1512,8 @@ QBitmap QPixmap::mask() const return QBitmap(); const QImage img = toImage(); - const QImage image = (img.depth() < 32 ? img.convertToFormat(QImage::Format_ARGB32_Premultiplied) : img); + bool shouldConvert = (img.format() != QImage::Format_ARGB32 && img.format() != QImage::Format_ARGB32_Premultiplied); + const QImage image = (shouldConvert ? img.convertToFormat(QImage::Format_ARGB32_Premultiplied) : img); const int w = image.width(); const int h = image.height(); @@ -1723,8 +1725,19 @@ QPlatformPixmap* QPixmap::handle() const #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug dbg, const QPixmap &r) { - dbg.nospace() << "QPixmap(" << r.size() << ')'; - return dbg.space(); + QDebugStateSaver saver(dbg); + dbg.resetFormat(); + dbg.nospace(); + dbg << "QPixmap("; + if (r.isNull()) { + dbg << "null"; + } else { + dbg << r.size() << ",depth=" << r.depth() + << ",devicePixelRatio=" << r.devicePixelRatio() + << ",cacheKey=" << showbase << hex << r.cacheKey() << dec << noshowbase; + } + dbg << ')'; + return dbg; } #endif |