diff options
Diffstat (limited to 'src/gui/image')
32 files changed, 361 insertions, 221 deletions
diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp index 2453242fa8..455045eb57 100644 --- a/src/gui/image/qbitmap.cpp +++ b/src/gui/image/qbitmap.cpp @@ -310,6 +310,7 @@ QBitmap QBitmap::transformed(const QTransform &matrix) const return bm; } +#if QT_DEPRECATED_SINCE(5, 13) /*! \overload \obsolete @@ -321,5 +322,6 @@ QBitmap QBitmap::transformed(const QMatrix &matrix) const { return transformed(QTransform(matrix)); } +#endif QT_END_NAMESPACE diff --git a/src/gui/image/qbitmap.h b/src/gui/image/qbitmap.h index 188064fccf..f7895bb1e0 100644 --- a/src/gui/image/qbitmap.h +++ b/src/gui/image/qbitmap.h @@ -76,7 +76,10 @@ public: static QBitmap fromData(const QSize &size, const uchar *bits, QImage::Format monoFormat = QImage::Format_MonoLSB); +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED_X("Use QBitmap::transformed(QTransform) instead") QBitmap transformed(const QMatrix &) const; +#endif QBitmap transformed(const QTransform &matrix) const; typedef QExplicitlySharedDataPointer<QPlatformPixmap> DataPtr; diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 7257853c3e..7f8e072322 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -866,10 +866,12 @@ void QBmpHandler::setOption(ImageOption option, const QVariant &value) Q_UNUSED(value); } +#if QT_DEPRECATED_SINCE(5, 13) QByteArray QBmpHandler::name() const { return formatName(); } +#endif QT_END_NAMESPACE diff --git a/src/gui/image/qbmphandler_p.h b/src/gui/image/qbmphandler_p.h index 56b39dd0f0..33b5b9c501 100644 --- a/src/gui/image/qbmphandler_p.h +++ b/src/gui/image/qbmphandler_p.h @@ -113,8 +113,9 @@ public: bool read(QImage *image) override; bool write(const QImage &image) override; +#if QT_DEPRECATED_SINCE(5, 13) QByteArray name() const override; - +#endif static bool canRead(QIODevice *device); QVariant option(ImageOption option) const override; diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index c362d0dc3f..c3c4b24678 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -315,9 +315,9 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St % HexString<uint>(actualSize.height()); if (mode == QIcon::Active) { - if (QPixmapCache::find(key % HexString<uint>(mode), pm)) + if (QPixmapCache::find(key % HexString<uint>(mode), &pm)) return pm; // horray - if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)) { + if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), &pm)) { QPixmap active = pm; if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>(qApp)) active = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(QIcon::Active, pm); @@ -326,7 +326,7 @@ QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::St } } - if (!QPixmapCache::find(key % HexString<uint>(mode), pm)) { + if (!QPixmapCache::find(key % HexString<uint>(mode), &pm)) { if (pm.size() != actualSize) pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); if (pe->mode != mode && mode != QIcon::Normal) { @@ -1080,11 +1080,12 @@ void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State if (!d) { QFileInfo info(fileName); - QIconEngine *engine = iconEngineFromSuffix(fileName, info.suffix()); + QString suffix = info.suffix(); #if QT_CONFIG(mimetype) - if (!engine) - engine = iconEngineFromSuffix(fileName, QMimeDatabase().mimeTypeForFile(info).preferredSuffix()); + if (suffix.isEmpty()) + suffix = QMimeDatabase().mimeTypeForFile(info).preferredSuffix(); // determination from contents #endif // mimetype + QIconEngine *engine = iconEngineFromSuffix(fileName, suffix); d = new QIconPrivate(engine ? engine : new QPixmapIconEngine); } diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h index 6a4fc8927a..8870950982 100644 --- a/src/gui/image/qicon.h +++ b/src/gui/image/qicon.h @@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE class QIconPrivate; class QIconEngine; +class QPainter; class Q_GUI_EXPORT QIcon { diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 3e18ca6528..0463ef6a42 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -117,7 +117,7 @@ QImageData::QImageData() */ QImageData * QImageData::create(const QSize &size, QImage::Format format) { - if (!size.isValid() || format == QImage::Format_Invalid) + if (size.isEmpty() || format == QImage::Format_Invalid) return nullptr; // invalid parameter(s) int width = size.width(); @@ -288,6 +288,7 @@ bool QImageData::checkForAlphaPixels() const case QImage::Format_BGR30: case QImage::Format_RGB30: case QImage::Format_Grayscale8: + case QImage::Format_Grayscale16: case QImage::Format_RGBX64: break; case QImage::Format_Invalid: @@ -710,6 +711,7 @@ bool QImageData::checkForAlphaPixels() const \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_RGBX64 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) @@ -1448,6 +1450,7 @@ void QImage::setDevicePixelRatio(qreal scaleFactor) d->devicePixelRatio = scaleFactor; } +#if QT_DEPRECATED_SINCE(5, 10) /*! \since 4.6 \obsolete @@ -1464,6 +1467,7 @@ int QImage::byteCount() const Q_ASSERT(!d || d->nbytes < std::numeric_limits<int>::max()); return d ? int(d->nbytes) : 0; } +#endif /*! \since 5.10 @@ -2045,6 +2049,7 @@ static bool highColorPrecision(QImage::Format format) case QImage::Format_RGBX64: case QImage::Format_RGBA64: case QImage::Format_RGBA64_Premultiplied: + case QImage::Format_Grayscale16: return true; default: break; @@ -2066,13 +2071,7 @@ QImage QImage::convertToFormat_helper(Format format, Qt::ImageConversionFlags fl Image_Converter converter = qimage_converter_map[d->format][format]; if (!converter && format > QImage::Format_Indexed8 && d->format > QImage::Format_Indexed8) { if (highColorPrecision(format) && highColorPrecision(d->format)) { - // Convert over RGBA64_Premultiplied - if (format == QImage::Format_RGBA64_Premultiplied) - converter = convert_generic_to_rgb64; - else { - Q_ASSERT(d->format != QImage::Format_RGBA64_Premultiplied); - return convertToFormat(Format_RGBA64_Premultiplied, flags).convertToFormat(format, flags); - } + converter = convert_generic_to_rgb64; } else converter = convert_generic; } @@ -2253,6 +2252,29 @@ bool QImage::reinterpretAsFormat(Format format) } /*! + \since 5.13 + + Detach and convert the image to the given \a format in place. + + The specified image conversion \a flags control how the image data + is handled during the conversion process. + + \sa convertToFormat() +*/ + +void QImage::convertTo(Format format, Qt::ImageConversionFlags flags) +{ + if (!d || format == QImage::Format_Invalid) + return; + + detach(); + if (convertToFormat_inplace(format, flags)) + return; + + *this = convertToFormat_helper(format, flags); +} + +/*! \fn bool QImage::valid(const QPoint &pos) const Returns \c true if \a pos is a valid coordinate pair within the @@ -2538,6 +2560,10 @@ QColor QImage::pixelColor(int x, int y) const case Format_RGBA64_Premultiplied: c = reinterpret_cast<const QRgba64 *>(s)[x]; break; + case Format_Grayscale16: { + quint16 v = reinterpret_cast<const quint16 *>(s)[x]; + return QColor(qRgba64(v, v, v, 0xffff)); + } default: c = QRgba64::fromArgb32(pixel(x, y)); break; @@ -2648,6 +2674,7 @@ bool QImage::allGray() const case Format_Alpha8: return false; case Format_Grayscale8: + case Format_Grayscale16: return true; case Format_RGB32: case Format_ARGB32: @@ -2714,7 +2741,7 @@ bool QImage::isGrayscale() const if (d->format == QImage::Format_Alpha8) return false; - if (d->format == QImage::Format_Grayscale8) + if (d->format == QImage::Format_Grayscale8 || d->format == QImage::Format_Grayscale16) return true; switch (depth()) { @@ -3348,6 +3375,7 @@ QImage QImage::rgbSwapped_helper() const break; case Format_Alpha8: case Format_Grayscale8: + case Format_Grayscale16: return *this; case Format_Mono: case Format_MonoLSB: @@ -3459,6 +3487,7 @@ void QImage::rgbSwapped_inplace() break; case Format_Alpha8: case Format_Grayscale8: + case Format_Grayscale16: return; case Format_Mono: case Format_MonoLSB: @@ -5356,6 +5385,19 @@ static Q_CONSTEXPR QPixelFormat pixelformats[] = { /*PREMULTIPLIED*/ QPixelFormat::Premultiplied, /*INTERPRETATION*/ QPixelFormat::UnsignedShort, /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian), + //QImage::Format_Grayscale16: + QPixelFormat(QPixelFormat::Grayscale, + /*GRAY*/ 16, + /*SECOND*/ 0, + /*THIRD*/ 0, + /*FOURTH*/ 0, + /*FIFTH*/ 0, + /*ALPHA*/ 0, + /*ALPHA USAGE*/ QPixelFormat::IgnoresAlpha, + /*ALPHA POSITION*/ QPixelFormat::AtBeginning, + /*PREMULTIPLIED*/ QPixelFormat::NotPremultiplied, + /*INTERPRETATION*/ QPixelFormat::UnsignedShort, + /*BYTE ORDER*/ QPixelFormat::CurrentSystemEndian), }; Q_STATIC_ASSERT(sizeof(pixelformats) / sizeof(*pixelformats) == QImage::NImageFormats); diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h index 6505fd5845..8335e117f2 100644 --- a/src/gui/image/qimage.h +++ b/src/gui/image/qimage.h @@ -128,10 +128,7 @@ public: Format_RGBX64, Format_RGBA64, Format_RGBA64_Premultiplied, -#if 0 - // reserved for future use Format_Grayscale16, -#endif #ifndef Q_QDOC NImageFormats #endif @@ -199,6 +196,8 @@ public: Q_REQUIRED_RESULT QImage convertToFormat(Format f, const QVector<QRgb> &colorTable, Qt::ImageConversionFlags flags = Qt::AutoColor) const; bool reinterpretAsFormat(Format f); + void convertTo(Format f, Qt::ImageConversionFlags flags = Qt::AutoColor); + int width() const; int height() const; QSize size() const; diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 215dd33499..82ffb8af8b 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -223,18 +223,29 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio void convert_generic_to_rgb64(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) { - Q_ASSERT(dest->format == QImage::Format_RGBA64_Premultiplied); + Q_ASSERT(dest->format > QImage::Format_Indexed8); Q_ASSERT(src->format > QImage::Format_Indexed8); + QRgba64 buf[BufferSize]; + QRgba64 *buffer = buf; const QPixelLayout *srcLayout = &qPixelLayouts[src->format]; + const QPixelLayout *destLayout = &qPixelLayouts[dest->format]; const uchar *srcData = src->data; uchar *destData = dest->data; const FetchAndConvertPixelsFunc64 fetch = srcLayout->fetchToRGBA64PM; + const ConvertAndStorePixelsFunc64 store = qStoreFromRGBA64PM[dest->format]; for (int y = 0; y < src->height; ++y) { - const QRgba64 *ptr = fetch((QRgba64*)destData, srcData, 0, src->width, nullptr, nullptr); - if (ptr != (const QRgba64*)destData) { - memcpy(destData, ptr, dest->bytes_per_line); + int x = 0; + while (x < src->width) { + int l = src->width - x; + if (destLayout->bpp == QPixelLayout::BPP64) + buffer = reinterpret_cast<QRgba64 *>(destData) + x; + else + l = qMin(l, BufferSize); + const QRgba64 *ptr = fetch(buffer, srcData, x, l, nullptr, nullptr); + store(destData, ptr, x, l, nullptr, nullptr); + x += l; } srcData += src->bytes_per_line; destData += dest->bytes_per_line; @@ -1205,33 +1216,6 @@ static void convert_RGBA64_to_ARGB32(QImageData *dest, const QImageData *src, Qt } template<bool RGBA> -static void convert_RGBA64PM_to_ARGB32(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) -{ - Q_ASSERT(src->format == QImage::Format_RGBA64_Premultiplied); - Q_ASSERT(RGBA || dest->format == QImage::Format_ARGB32); - Q_ASSERT(!RGBA || dest->format == QImage::Format_RGBA8888); - Q_ASSERT(src->width == dest->width); - Q_ASSERT(src->height == dest->height); - - const int src_pad = (src->bytes_per_line >> 3) - src->width; - const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; - const QRgba64 *src_data = reinterpret_cast<const QRgba64 *>(src->data); - uint *dest_data = reinterpret_cast<uint *>(dest->data); - - for (int i = 0; i < src->height; ++i) { - const QRgba64 *end = src_data + src->width; - while (src_data < end) { - QRgba64 s = src_data->unpremultiplied(); - *dest_data = RGBA ? ARGB2RGBA(s.toArgb32()) : s.toArgb32(); - ++src_data; - ++dest_data; - } - src_data += src_pad; - dest_data += dest_pad; - } -} - -template<bool RGBA> static void convert_ARGB32_to_RGBA64(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) { Q_ASSERT(RGBA || src->format == QImage::Format_ARGB32); @@ -1240,74 +1224,14 @@ static void convert_ARGB32_to_RGBA64(QImageData *dest, const QImageData *src, Qt Q_ASSERT(src->width == dest->width); Q_ASSERT(src->height == dest->height); - const int src_pad = (src->bytes_per_line >> 2) - src->width; - const int dest_pad = (dest->bytes_per_line >> 3) - dest->width; - const uint *src_data = reinterpret_cast<const uint *>(src->data); - QRgba64 *dest_data = reinterpret_cast<QRgba64 *>(dest->data); - - for (int i = 0; i < src->height; ++i) { - const uint *end = src_data + src->width; - while (src_data < end) { - if (RGBA) - *dest_data = QRgba64::fromArgb32(RGBA2ARGB(*src_data)); - else - *dest_data = QRgba64::fromArgb32(*src_data); - ++src_data; - ++dest_data; - } - src_data += src_pad; - dest_data += dest_pad; - } -} - -template<QtPixelOrder PixelOrder> -static void convert_RGBA64PM_to_RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) -{ - Q_ASSERT(src->format == QImage::Format_RGBA64_Premultiplied); - Q_ASSERT(dest->format == QImage::Format_RGB30 || dest->format == QImage::Format_BGR30); - Q_ASSERT(src->width == dest->width); - Q_ASSERT(src->height == dest->height); - - const int src_pad = (src->bytes_per_line >> 3) - src->width; - const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; - const QRgba64 *src_data = reinterpret_cast<const QRgba64 *>(src->data); - uint *dest_data = reinterpret_cast<uint *>(dest->data); - - for (int i = 0; i < src->height; ++i) { - const QRgba64 *end = src_data + src->width; - while (src_data < end) { - *dest_data = 0xc0000000 | qConvertRgb64ToRgb30<PixelOrder>(src_data->unpremultiplied()); - ++src_data; - ++dest_data; - } - src_data += src_pad; - dest_data += dest_pad; - } -} - -template<QtPixelOrder PixelOrder> -static void convert_RGBA64PM_to_A2RGB30(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) -{ - Q_ASSERT(src->format == QImage::Format_RGBA64_Premultiplied); - Q_ASSERT(dest->format == QImage::Format_A2RGB30_Premultiplied - || dest->format == QImage::Format_A2BGR30_Premultiplied); - Q_ASSERT(src->width == dest->width); - Q_ASSERT(src->height == dest->height); - - const int src_pad = (src->bytes_per_line >> 3) - src->width; - const int dest_pad = (dest->bytes_per_line >> 2) - dest->width; - const QRgba64 *src_data = reinterpret_cast<const QRgba64 *>(src->data); - uint *dest_data = reinterpret_cast<uint *>(dest->data); + const uchar *src_data = src->data; + uchar *dest_data = dest->data; + const FetchAndConvertPixelsFunc64 fetch = qPixelLayouts[src->format + 1].fetchToRGBA64PM; for (int i = 0; i < src->height; ++i) { - const QRgba64 *end = src_data + src->width; - while (src_data < end) { - *dest_data = qConvertRgb64ToRgb30<PixelOrder>(*src_data); - ++src_data; - ++dest_data; - } - src_data += src_pad; - dest_data += dest_pad; + fetch(reinterpret_cast<QRgba64 *>(dest_data), src_data, 0, src->width, nullptr, nullptr); + src_data += src->bytes_per_line;; + dest_data += dest->bytes_per_line; } } @@ -1447,6 +1371,56 @@ static bool convert_RGBA64PM_to_RGBA64_inplace(QImageData *data, Qt::ImageConver return true; } +static void convert_gray16_to_RGBA64(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) +{ + Q_ASSERT(src->format == QImage::Format_Grayscale16); + Q_ASSERT(dest->format == QImage::Format_RGBA64 || dest->format == QImage::Format_RGBX64 || + dest->format == QImage::Format_RGBA64_Premultiplied); + Q_ASSERT(src->width == dest->width); + Q_ASSERT(src->height == dest->height); + + const qsizetype sbpl = src->bytes_per_line; + const qsizetype dbpl = dest->bytes_per_line; + const uchar *src_data = src->data; + uchar *dest_data = dest->data; + + for (int i = 0; i < src->height; ++i) { + const quint16 *src_line = reinterpret_cast<const quint16 *>(src_data); + QRgba64 *dest_line = reinterpret_cast<QRgba64 *>(dest_data); + for (int j = 0; j < src->width; ++j) { + quint16 s = src_line[j]; + dest_line[j] = qRgba64(s, s, s, 0xFFFF); + } + src_data += sbpl; + dest_data += dbpl; + } +} + +static void convert_RGBA64_to_gray16(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) +{ + Q_ASSERT(dest->format == QImage::Format_Grayscale16); + Q_ASSERT(src->format == QImage::Format_RGBX64 || + src->format == QImage::Format_RGBA64_Premultiplied); + Q_ASSERT(src->width == dest->width); + Q_ASSERT(src->height == dest->height); + + const qsizetype sbpl = src->bytes_per_line; + const qsizetype dbpl = dest->bytes_per_line; + const uchar *src_data = src->data; + uchar *dest_data = dest->data; + + for (int i = 0; i < src->height; ++i) { + const QRgba64 *src_line = reinterpret_cast<const QRgba64 *>(src_data); + quint16 *dest_line = reinterpret_cast<quint16 *>(dest_data); + for (int j = 0; j < src->width; ++j) { + QRgba64 s = src_line[j].unpremultiplied(); + dest_line[j] = qGray(s.red(), s.green(), s.blue()); + } + src_data += sbpl; + dest_data += dbpl; + } +} + static QVector<QRgb> fix_color_table(const QVector<QRgb> &ctbl, QImage::Format format) { QVector<QRgb> colorTable = ctbl; @@ -2291,7 +2265,7 @@ static bool convert_Grayscale8_to_Indexed8_inplace(QImageData *data, Qt::ImageCo Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormats] = { { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, @@ -2312,7 +2286,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_Mono { @@ -2334,7 +2308,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_MonoLSB { @@ -2359,7 +2333,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, 0, 0, convert_Indexed8_to_Alpha8, convert_Indexed8_to_Grayscale8, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_Indexed8 { @@ -2387,7 +2361,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat convert_RGB_to_RGB30<PixelOrderRGB, false>, 0, 0, 0, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_RGB32 { @@ -2417,7 +2391,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, convert_ARGB32_to_RGBA64<false>, - 0 + 0, 0 }, // Format_ARGB32 { @@ -2442,7 +2416,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat convert_ARGB_to_RGBA, 0, 0, 0, 0, 0, 0, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_ARGB32_Premultiplied { @@ -2464,7 +2438,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGB16 { @@ -2486,7 +2460,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_ARGB8565_Premultiplied { @@ -2508,7 +2482,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGB666 { @@ -2530,7 +2504,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_ARGB6666_Premultiplied { @@ -2552,7 +2526,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGB555 { @@ -2574,7 +2548,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_ARGB8555_Premultiplied { @@ -2597,7 +2571,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat convert_RGB888_to_RGB<true>, convert_RGB888_to_RGB<true>, convert_RGB888_to_RGB<true>, - 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGB888 { @@ -2619,7 +2593,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGB444 { @@ -2640,7 +2614,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_ARGB4444_Premultiplied { 0, @@ -2667,7 +2641,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat convert_RGB_to_RGB30<PixelOrderRGB, true>, 0, 0, 0, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_RGBX8888 { 0, @@ -2696,7 +2670,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, convert_ARGB32_to_RGBA64<true>, - 0 + 0, 0 }, // Format_RGBA8888 { @@ -2718,7 +2692,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGBA8888_Premultiplied { @@ -2746,7 +2720,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat convert_BGR30_to_RGB30, convert_BGR30_to_RGB30, 0, 0, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_BGR30 { 0, @@ -2773,8 +2747,8 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat convert_A2RGB30_PM_to_RGB30<true>, convert_BGR30_to_RGB30, 0, 0, - 0, 0, 0 - }, // Format_BGR30A2_Premultiplied + 0, 0, 0, 0 + }, // Format_A2BGR30_Premultiplied { 0, 0, @@ -2799,7 +2773,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat convert_BGR30_to_RGB30, 0, convert_passthrough, - 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0 }, // Format_RGB30 { 0, @@ -2826,8 +2800,8 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat convert_A2RGB30_PM_to_RGB30<false>, 0, 0, 0, - 0, 0, 0 - }, // Format_RGB30A2_Premultiplied + 0, 0, 0, 0 + }, // Format_A2RGB30_Premultiplied { 0, 0, @@ -2846,7 +2820,7 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_Alpha8 { 0, @@ -2872,7 +2846,8 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // self convert_passthrough, - convert_passthrough + convert_passthrough, + convert_RGBA64_to_gray16 }, // Format_RGBX64 { 0, @@ -2898,7 +2873,8 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, convert_RGBA64_to_RGBx64, 0, // self - convert_RGBA64_to_RGBA64PM + convert_RGBA64_to_RGBA64PM, + 0 }, // Format_RGBA64 { 0, @@ -2906,7 +2882,6 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - convert_RGBA64PM_to_ARGB32<false>, 0, 0, 0, @@ -2918,29 +2893,58 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat 0, 0, 0, - convert_RGBA64PM_to_ARGB32<true>, 0, - convert_RGBA64PM_to_RGB30<PixelOrderBGR>, - convert_RGBA64PM_to_A2RGB30<PixelOrderBGR>, - convert_RGBA64PM_to_RGB30<PixelOrderRGB>, - convert_RGBA64PM_to_A2RGB30<PixelOrderRGB>, + 0, + 0, + 0, 0, 0, 0, 0, 0, convert_RGBA64PM_to_RGBA64<true>, convert_RGBA64PM_to_RGBA64<false>, - 0 // self - } // Format_RGBA64_Premultiplied + 0, // self + convert_RGBA64_to_gray16 + }, // Format_RGBA64_Premultiplied + { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, 0, + convert_gray16_to_RGBA64, + convert_gray16_to_RGBA64, + convert_gray16_to_RGBA64, + 0 // self + }, // Format_Grayscale16 }; InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QImage::NImageFormats] = { { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_Mono { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_MonoLSB { 0, @@ -2964,7 +2968,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, 0, 0, convert_Indexed8_to_Alpha8_inplace, convert_Indexed8_to_Grayscale8_inplace, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_Indexed8 { 0, @@ -2991,7 +2995,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma convert_RGB_to_RGB30_inplace<PixelOrderRGB, false>, 0, 0, 0, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_RGB32 { 0, @@ -3018,7 +3022,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma convert_RGB_to_RGB30_inplace<PixelOrderRGB, false>, 0, 0, 0, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_ARGB32 { 0, @@ -3042,34 +3046,34 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma convert_ARGB_to_RGBA_inplace<QImage::Format_RGBA8888_Premultiplied>, 0, 0, 0, 0, 0, 0, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_ARGB32_Premultiplied { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGB16 { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_ARGB8565_Premultiplied { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGB666 { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_ARGB6666_Premultiplied { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGB555 { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_ARGB8555_Premultiplied { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGB888 { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGB444 { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_ARGB4444_Premultiplied { 0, @@ -3096,7 +3100,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma convert_RGB_to_RGB30_inplace<PixelOrderRGB, true>, 0, 0, 0, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_RGBX8888 { 0, @@ -3123,7 +3127,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma convert_RGB_to_RGB30_inplace<PixelOrderRGB, true>, 0, 0, 0, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_RGBA8888 { 0, @@ -3145,7 +3149,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, // Format_RGBA8888_Premultiplied { 0, @@ -3172,7 +3176,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma convert_BGR30_to_RGB30_inplace, convert_BGR30_to_A2RGB30_inplace, 0, 0, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_BGR30 { 0, @@ -3198,8 +3202,8 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, // self convert_A2RGB30_PM_to_RGB30_inplace<true>, convert_BGR30_to_RGB30_inplace, - 0, 0, 0, 0, 0 - }, // Format_BGR30A2_Premultiplied + 0, 0, 0, 0, 0, 0 + }, // Format_A2BGR30_Premultiplied { 0, 0, @@ -3224,7 +3228,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma convert_BGR30_to_A2RGB30_inplace, 0, // self convert_passthrough_inplace<QImage::Format_A2RGB30_Premultiplied>, - 0, 0, 0, 0, 0 + 0, 0, 0, 0, 0, 0 }, // Format_RGB30 { 0, @@ -3251,8 +3255,8 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma convert_A2RGB30_PM_to_RGB30_inplace<false>, 0, // self 0, 0, - 0, 0, 0 - }, // Format_RGB30A2_Premultiplied + 0, 0, 0, 0 + }, // Format_A2RGB30_Premultiplied { 0, 0, @@ -3276,7 +3280,7 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, 0, 0, // self 0, - 0, 0, 0 + 0, 0, 0, 0 }, // Format_Alpha8 { 0, @@ -3301,26 +3305,32 @@ InPlace_Image_Converter qimage_inplace_converter_map[QImage::NImageFormats][QIma 0, 0, 0, 0, 0, 0, // self - 0, 0, 0 + 0, 0, 0, 0 }, // Format_Grayscale8 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // self convert_passthrough_inplace<QImage::Format_RGBA64>, convert_passthrough_inplace<QImage::Format_RGBA64_Premultiplied>, + 0 }, // Format_RGBX64 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, convert_RGBA64_to_RGBx64_inplace, 0, // self - convert_RGBA64_to_RGBA64PM_inplace + convert_RGBA64_to_RGBA64PM_inplace, + 0 }, // Format_RGBA64 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, convert_RGBA64PM_to_RGBA64_inplace<true>, convert_RGBA64PM_to_RGBA64_inplace<false>, - 0 // self - } // Format_RGBA64_Premultiplied + 0, // self + 0 + }, // Format_RGBA64_Premultiplied + { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }, // Format_Grayscale16 }; static void qInitImageConversions() diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h index a0a3b5406e..d88ad2d1d2 100644 --- a/src/gui/image/qimage_p.h +++ b/src/gui/image/qimage_p.h @@ -195,6 +195,7 @@ inline int qt_depthForFormat(QImage::Format format) case QImage::Format_RGB16: case QImage::Format_RGB444: case QImage::Format_ARGB4444_Premultiplied: + case QImage::Format_Grayscale16: depth = 16; break; case QImage::Format_RGB666: diff --git a/src/gui/image/qimageiohandler.cpp b/src/gui/image/qimageiohandler.cpp index 5d1f8fa91f..0e7b541cf2 100644 --- a/src/gui/image/qimageiohandler.cpp +++ b/src/gui/image/qimageiohandler.cpp @@ -340,7 +340,7 @@ void QImageIOHandler::setDevice(QIODevice *device) /*! Returns the device currently assigned to the QImageIOHandler. If - not device has been assigned, 0 is returned. + not device has been assigned, \nullptr is returned. */ QIODevice *QImageIOHandler::device() const { @@ -416,6 +416,7 @@ QByteArray QImageIOHandler::format() const \sa read(), QIODevice::peek() */ +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete @@ -426,6 +427,7 @@ QByteArray QImageIOHandler::name() const { return format(); } +#endif /*! Writes the image \a image to the assigned device. Returns \c true on diff --git a/src/gui/image/qimageiohandler.h b/src/gui/image/qimageiohandler.h index 35984dd6a5..c20b84afbb 100644 --- a/src/gui/image/qimageiohandler.h +++ b/src/gui/image/qimageiohandler.h @@ -69,7 +69,10 @@ public: void setFormat(const QByteArray &format) const; QByteArray format() const; +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED_X("Use QImageIOHandler::format() instead") virtual QByteArray name() const; +#endif virtual bool canRead() const = 0; virtual bool read(QImage *image) = 0; @@ -141,7 +144,7 @@ class Q_GUI_EXPORT QImageIOPlugin : public QObject Q_OBJECT public: explicit QImageIOPlugin(QObject *parent = nullptr); - virtual ~QImageIOPlugin(); + ~QImageIOPlugin(); enum Capability { CanRead = 0x1, diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 0fb1d808e5..61f20e0c65 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -526,7 +526,7 @@ bool QImageReaderPrivate::initHandler() // Try the most probable extension first int currentFormatIndex = extensions.indexOf(format.toLower()); if (currentFormatIndex > 0) - extensions.swap(0, currentFormatIndex); + extensions.swapItemsAt(0, currentFormatIndex); } int currentExtension = 0; @@ -756,13 +756,13 @@ void QImageReader::setDevice(QIODevice *device) d->device = device; d->deleteDevice = false; delete d->handler; - d->handler = 0; + d->handler = nullptr; d->text.clear(); } /*! - Returns the device currently assigned to QImageReader, or 0 if no - device has been assigned. + Returns the device currently assigned to QImageReader, or \nullptr + if no device has been assigned. */ QIODevice *QImageReader::device() const { diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index d3f9a9b881..ec66588ddf 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -407,8 +407,8 @@ void QImageWriter::setDevice(QIODevice *device) } /*! - Returns the device currently assigned to QImageWriter, or 0 if no - device has been assigned. + Returns the device currently assigned to QImageWriter, or \nullptr + if no device has been assigned. */ QIODevice *QImageWriter::device() const { @@ -648,6 +648,7 @@ QImageIOHandler::Transformations QImageWriter::transformation() const return d->transformation; } +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete @@ -679,6 +680,7 @@ QString QImageWriter::description() const { return d->description; } +#endif /*! \since 4.1 diff --git a/src/gui/image/qimagewriter.h b/src/gui/image/qimagewriter.h index 29c06ccdd2..ef84a59b7c 100644 --- a/src/gui/image/qimagewriter.h +++ b/src/gui/image/qimagewriter.h @@ -100,9 +100,12 @@ public: QImageIOHandler::Transformations transformation() const; void setTransformation(QImageIOHandler::Transformations orientation); - // Obsolete as of 4.1 +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED_X("Use QImageWriter::setText() instead") void setDescription(const QString &description); + QT_DEPRECATED_X("Use QImageReader::text() instead") QString description() const; +#endif void setText(const QString &key, const QString &text); diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp index 7d17b7d5ef..79203c7b98 100644 --- a/src/gui/image/qmovie.cpp +++ b/src/gui/image/qmovie.cpp @@ -659,7 +659,7 @@ void QMovie::setDevice(QIODevice *device) /*! Returns the device QMovie reads image data from. If no device has - currently been assigned, 0 is returned. + currently been assigned, \nullptr is returned. \sa setDevice(), fileName() */ diff --git a/src/gui/image/qpaintengine_pic_p.h b/src/gui/image/qpaintengine_pic_p.h index c3044796ad..c9e4b43197 100644 --- a/src/gui/image/qpaintengine_pic_p.h +++ b/src/gui/image/qpaintengine_pic_p.h @@ -103,7 +103,7 @@ protected: QPicturePaintEngine(QPaintEnginePrivate &dptr); private: - Q_DISABLE_COPY(QPicturePaintEngine) + Q_DISABLE_COPY_MOVE(QPicturePaintEngine) void writeCmdLength(int pos, const QRectF &r, bool corr); }; diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 2f2f85f68d..56b82abcfa 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -858,7 +858,7 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords) break; case QPicturePrivate::PdcSetWXform: s >> i_8; - painter->setMatrixEnabled(i_8); + painter->setWorldMatrixEnabled(i_8); break; case QPicturePrivate::PdcSetWMatrix: if (d->formatMajor >= 8) { @@ -1200,8 +1200,8 @@ QT_END_INCLUDE_NAMESPACE \obsolete Returns a string that specifies the picture format of the file \a - fileName, or 0 if the file cannot be read or if the format is not - recognized. + fileName, or \nullptr if the file cannot be read or if the format + is not recognized. \sa load(), save() */ @@ -1543,7 +1543,7 @@ const QPicture &QPictureIO::picture() const { return d->pi; } int QPictureIO::status() const { return d->iostat; } /*! - Returns the picture format string or 0 if no format has been + Returns the picture format string or \nullptr if no format has been explicitly set. */ const char *QPictureIO::format() const { return d->frmt; } diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index ea6697cc39..2ef1d09422 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -858,6 +858,7 @@ bool QPixmap::doImageIO(QImageWriter *writer, int quality) const } +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete @@ -878,6 +879,14 @@ void QPixmap::fill(const QPaintDevice *device, const QPoint &p) Use QPainter or the fill(QColor) overload instead. */ +void QPixmap::fill(const QPaintDevice *device, int xofs, int yofs) +{ + Q_UNUSED(device) + Q_UNUSED(xofs) + Q_UNUSED(yofs) + qWarning("this function is deprecated, ignored"); +} +#endif /*! @@ -961,6 +970,7 @@ static void sendResizeEvents(QWidget *target) } #endif +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete @@ -984,6 +994,14 @@ QPixmap QPixmap::grabWidget(QObject *widget, const QRect &rectangle) Use QWidget::grab() instead. */ +QPixmap QPixmap::grabWidget(QObject *widget, int x, int y, int w, int h) +{ +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED + return grabWidget(widget, QRect(x, y, w, h)); +QT_WARNING_POP +} +#endif /***************************************************************************** QPixmap stream functions @@ -1358,12 +1376,6 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) The cacheKey() function returns a number that uniquely identifies the contents of the QPixmap object. - The x11Info() function returns information about the configuration - of the X display used by the screen to which the pixmap currently - belongs. The x11PictureHandle() function returns the X11 Picture - handle of the pixmap for XRender support. Note that the two latter - functions are only available on x11. - \endtable \section1 Pixmap Conversion @@ -1394,9 +1406,6 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) function returns the actual matrix used for transforming the pixmap. - \note When using the native X11 graphics system, the pixmap - becomes invalid when the QApplication instance is destroyed. - \sa QBitmap, QImage, QImageReader, QImageWriter */ @@ -1589,6 +1598,7 @@ QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionF return QPixmap(data.take()); } +#if QT_DEPRECATED_SINCE(5, 13) /*! \fn QPixmap QPixmap::grabWindow(WId window, int x, int y, int width, int height) @@ -1642,6 +1652,7 @@ QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) " Defaulting to primary screen."); return QGuiApplication::primaryScreen()->grabWindow(window, x, y, w, h); } +#endif /*! \internal diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h index 55cca7a766..13c81f18d0 100644 --- a/src/gui/image/qpixmap.h +++ b/src/gui/image/qpixmap.h @@ -94,8 +94,12 @@ public: static int defaultDepth(); void fill(const QColor &fillColor = Qt::white); +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED_X("Use QPainter or fill(QColor)") void fill(const QPaintDevice *device, const QPoint &ofs); - inline void fill(const QPaintDevice *device, int xofs, int yofs) { fill(device, QPoint(xofs, yofs)); } + QT_DEPRECATED_X("Use QPainter or fill(QColor)") + void fill(const QPaintDevice *device, int xofs, int yofs); +#endif QBitmap mask() const; void setMask(const QBitmap &); @@ -111,10 +115,14 @@ public: #endif QBitmap createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode = Qt::MaskInColor) const; - static QPixmap grabWindow(WId, int x=0, int y=0, int w=-1, int h=-1); +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED_X("Use QScreen::grabWindow() instead") + static QPixmap grabWindow(WId, int x = 0, int y = 0, int w = -1, int h = -1); + QT_DEPRECATED_X("Use QWidget::grab() instead") static QPixmap grabWidget(QObject *widget, const QRect &rect); - static inline QPixmap grabWidget(QObject *widget, int x=0, int y=0, int w=-1, int h=-1) - { return grabWidget(widget, QRect(x, y, w, h)); } + QT_DEPRECATED_X("Use QWidget::grab() instead") + static QPixmap grabWidget(QObject *widget, int x = 0, int y = 0, int w = -1, int h = -1); +#endif inline QPixmap scaled(int w, int h, Qt::AspectRatioMode aspectMode = Qt::IgnoreAspectRatio, Qt::TransformationMode mode = Qt::FastTransformation) const diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp index 13c1c29d5b..2732bbd197 100644 --- a/src/gui/image/qpixmap_raster.cpp +++ b/src/gui/image/qpixmap_raster.cpp @@ -203,6 +203,9 @@ void QRasterPlatformPixmap::fill(const QColor &color) pixel = qAlpha(color.rgba()); } else if (image.format() == QImage::Format_Grayscale8) { pixel = qGray(color.rgba()); + } else if (image.format() == QImage::Format_Grayscale16) { + QRgba64 c = color.rgba64(); + pixel = qGray(c.red(), c.green(), c.blue()); } else { pixel = 0; diff --git a/src/gui/image/qpixmap_win.cpp b/src/gui/image/qpixmap_win.cpp index b5f8d43041..3a2db74098 100644 --- a/src/gui/image/qpixmap_win.cpp +++ b/src/gui/image/qpixmap_win.cpp @@ -210,7 +210,7 @@ static QImage copyImageData(const BITMAPINFOHEADER &header, const RGBQUAD *color class DisplayHdc { - Q_DISABLE_COPY(DisplayHdc) + Q_DISABLE_COPY_MOVE(DisplayHdc) public: DisplayHdc() : m_displayDc(GetDC(nullptr)) {} ~DisplayHdc() { ReleaseDC(nullptr, m_displayDc); } diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 3d1652f68b..66907bebd7 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -469,10 +469,13 @@ QPixmapCacheEntry::~QPixmapCacheEntry() pm_cache()->releaseKey(key); } +#if QT_DEPRECATED_SINCE(5, 13) /*! \obsolete \overload + Use bool find(const QString &, QPixmap *) instead. + Returns the pixmap associated with the \a key in the cache, or null if there is no such pixmap. @@ -494,13 +497,14 @@ QPixmap *QPixmapCache::find(const QString &key) /*! \obsolete - Use bool find(const QString&, QPixmap*) instead. + Use bool find(const QString &, QPixmap *) instead. */ -bool QPixmapCache::find(const QString &key, QPixmap& pixmap) +bool QPixmapCache::find(const QString &key, QPixmap &pixmap) { return find(key, &pixmap); } +#endif /*! Looks for a cached pixmap associated with the given \a key in the cache. @@ -513,7 +517,7 @@ bool QPixmapCache::find(const QString &key, QPixmap& pixmap) \snippet code/src_gui_image_qpixmapcache.cpp 1 */ -bool QPixmapCache::find(const QString &key, QPixmap* pixmap) +bool QPixmapCache::find(const QString &key, QPixmap *pixmap) { QPixmap *ptr = pm_cache()->object(key); if (ptr && pixmap) @@ -530,7 +534,7 @@ bool QPixmapCache::find(const QString &key, QPixmap* pixmap) \since 4.6 */ -bool QPixmapCache::find(const Key &key, QPixmap* pixmap) +bool QPixmapCache::find(const Key &key, QPixmap *pixmap) { //The key is not valid anymore, a flush happened before probably if (!key.d || !key.d->isValid) diff --git a/src/gui/image/qpixmapcache.h b/src/gui/image/qpixmapcache.h index ea10ab1b76..12d05b00f3 100644 --- a/src/gui/image/qpixmapcache.h +++ b/src/gui/image/qpixmapcache.h @@ -76,8 +76,12 @@ public: static int cacheLimit(); static void setCacheLimit(int); +#if QT_DEPRECATED_SINCE(5, 13) + QT_DEPRECATED_X("Use bool find(const QString &, QPixmap *) instead") static QPixmap *find(const QString &key); + QT_DEPRECATED_X("Use bool find(const QString &, QPixmap *) instead") static bool find(const QString &key, QPixmap &pixmap); +#endif static bool find(const QString &key, QPixmap *pixmap); static bool find(const Key &key, QPixmap *pixmap); static bool insert(const QString &key, const QPixmap &pixmap); diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index 808037f434..140196004b 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -266,6 +266,18 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal else if (g == 1) image.setColor(0, qRgba(255, 255, 255, 0)); } + } else if (bit_depth == 16 + && png_get_channels(png_ptr, info_ptr) == 1 + && !png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { + if (image.size() != QSize(width, height) || image.format() != QImage::Format_Grayscale16) { + image = QImage(width, height, QImage::Format_Grayscale16); + if (image.isNull()) + return; + } + + png_read_update_info(png_ptr, info_ptr); + if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) + png_set_swap(png_ptr); } else if (bit_depth == 16) { bool hasMask = png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS); if (!hasMask) @@ -687,7 +699,7 @@ QImage::Format QPngHandlerPrivate::readImageFormat() if (bit_depth == 1 && png_get_channels(png_ptr, info_ptr) == 1) { format = QImage::Format_Mono; } else if (bit_depth == 16) { - format = png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ? QImage::Format_RGBA64 : QImage::Format_RGBX64; + format = png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS) ? QImage::Format_RGBA64 : QImage::Format_Grayscale16; } else if (bit_depth == 8 && !png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { format = QImage::Format_Grayscale8; } else { @@ -861,7 +873,8 @@ bool QPNGImageWriter::writeImage(const QImage& image, volatile int compression_i else color_type = PNG_COLOR_TYPE_PALETTE; } - else if (image.format() == QImage::Format_Grayscale8) + else if (image.format() == QImage::Format_Grayscale8 + || image.format() == QImage::Format_Grayscale16) color_type = PNG_COLOR_TYPE_GRAY; else if (image.hasAlphaChannel()) color_type = PNG_COLOR_TYPE_RGB_ALPHA; @@ -877,6 +890,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, volatile int compression_i case QImage::Format_RGBX64: case QImage::Format_RGBA64: case QImage::Format_RGBA64_Premultiplied: + case QImage::Format_Grayscale16: bpc = 16; break; default: @@ -988,6 +1002,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, volatile int compression_i case QImage::Format_RGBX64: case QImage::Format_RGBA64: case QImage::Format_RGBA64_Premultiplied: + case QImage::Format_Grayscale16: png_set_swap(png_ptr); break; default: @@ -1018,6 +1033,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, volatile int compression_i case QImage::Format_MonoLSB: case QImage::Format_Indexed8: case QImage::Format_Grayscale8: + case QImage::Format_Grayscale16: case QImage::Format_RGB32: case QImage::Format_ARGB32: case QImage::Format_RGB888: @@ -1181,10 +1197,12 @@ void QPngHandler::setOption(ImageOption option, const QVariant &value) d->scaledSize = value.toSize(); } +#if QT_DEPRECATED_SINCE(5, 13) QByteArray QPngHandler::name() const { return "png"; } +#endif QT_END_NAMESPACE diff --git a/src/gui/image/qpnghandler_p.h b/src/gui/image/qpnghandler_p.h index 4ca716e7c2..5d4da97395 100644 --- a/src/gui/image/qpnghandler_p.h +++ b/src/gui/image/qpnghandler_p.h @@ -69,7 +69,9 @@ public: bool read(QImage *image) override; bool write(const QImage &image) override; +#if QT_DEPRECATED_SINCE(5, 13) QByteArray name() const override; +#endif QVariant option(ImageOption option) const override; void setOption(ImageOption option, const QVariant &value) override; diff --git a/src/gui/image/qppmhandler.cpp b/src/gui/image/qppmhandler.cpp index 53e3fa293d..13ee2eadd2 100644 --- a/src/gui/image/qppmhandler.cpp +++ b/src/gui/image/qppmhandler.cpp @@ -68,13 +68,19 @@ static int read_pbm_int(QIODevice *d) char c; int val = -1; bool digit; + bool hasOverflow = false; for (;;) { if (!d->getChar(&c)) // end of file break; digit = isdigit((uchar) c); if (val != -1) { if (digit) { - val = 10*val + c - '0'; + const int cValue = c - '0'; + if (val <= (INT_MAX - cValue) / 10) { + val = 10*val + cValue; + } else { + hasOverflow = true; + } continue; } else { if (c == '#') // comment @@ -91,7 +97,7 @@ static int read_pbm_int(QIODevice *d) else break; } - return val; + return hasOverflow ? -1 : val; } static bool read_pbm_header(QIODevice *device, char& type, int& w, int& h, int& mcc) @@ -123,7 +129,7 @@ static bool read_pbm_header(QIODevice *device, char& type, int& w, int& h, int& static inline QRgb scale_pbm_color(quint16 mx, quint16 rv, quint16 gv, quint16 bv) { - return QRgba64::fromRgba64((rv * 0xffff) / mx, (gv * 0xffff) / mx, (bv * 0xffff) / mx, 0xffff).toArgb32(); + return QRgba64::fromRgba64((rv * 0xffffu) / mx, (gv * 0xffffu) / mx, (bv * 0xffffu) / mx, 0xffff).toArgb32(); } static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, QImage *outImage) @@ -252,7 +258,7 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q } } else { while (n--) { - *p++ = read_pbm_int(device) * 255 / mcc; + *p++ = (read_pbm_int(device) & 0xffff) * 255 / mcc; } } } else { // 32 bits @@ -570,10 +576,12 @@ void QPpmHandler::setOption(ImageOption option, const QVariant &value) subType = value.toByteArray().toLower(); } +#if QT_DEPRECATED_SINCE(5, 13) QByteArray QPpmHandler::name() const { return subType.isEmpty() ? QByteArray("ppm") : subType; } +#endif QT_END_NAMESPACE diff --git a/src/gui/image/qppmhandler_p.h b/src/gui/image/qppmhandler_p.h index 1c6fbd6869..f3c9d0f139 100644 --- a/src/gui/image/qppmhandler_p.h +++ b/src/gui/image/qppmhandler_p.h @@ -67,7 +67,9 @@ public: bool read(QImage *image) override; bool write(const QImage &image) override; +#if QT_DEPRECATED_SINCE(5, 13) QByteArray name() const override; +#endif static bool canRead(QIODevice *device, QByteArray *subType = 0); diff --git a/src/gui/image/qxbmhandler.cpp b/src/gui/image/qxbmhandler.cpp index 7ba44049b4..65a5b63bc7 100644 --- a/src/gui/image/qxbmhandler.cpp +++ b/src/gui/image/qxbmhandler.cpp @@ -356,10 +356,12 @@ void QXbmHandler::setOption(ImageOption option, const QVariant &value) fileName = value.toString(); } +#if QT_DEPRECATED_SINCE(5, 13) QByteArray QXbmHandler::name() const { return "xbm"; } +#endif QT_END_NAMESPACE diff --git a/src/gui/image/qxbmhandler_p.h b/src/gui/image/qxbmhandler_p.h index 26439af527..ae590a1944 100644 --- a/src/gui/image/qxbmhandler_p.h +++ b/src/gui/image/qxbmhandler_p.h @@ -66,7 +66,9 @@ public: bool read(QImage *image) override; bool write(const QImage &image) override; +#if QT_DEPRECATED_SINCE(5, 13) QByteArray name() const override; +#endif static bool canRead(QIODevice *device); diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index 17272ffe69..a32dfda96d 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1287,10 +1287,12 @@ void QXpmHandler::setOption(ImageOption option, const QVariant &value) fileName = value.toString(); } +#if QT_DEPRECATED_SINCE(5, 13) QByteArray QXpmHandler::name() const { return "xpm"; } +#endif QT_END_NAMESPACE diff --git a/src/gui/image/qxpmhandler_p.h b/src/gui/image/qxpmhandler_p.h index f118bf2309..a4dd88cd17 100644 --- a/src/gui/image/qxpmhandler_p.h +++ b/src/gui/image/qxpmhandler_p.h @@ -68,7 +68,9 @@ public: static bool canRead(QIODevice *device); +#if QT_DEPRECATED_SINCE(5, 13) QByteArray name() const override; +#endif QVariant option(ImageOption option) const override; void setOption(ImageOption option, const QVariant &value) override; |