diff options
Diffstat (limited to 'src/gui/image/qimage.cpp')
-rw-r--r-- | src/gui/image/qimage.cpp | 177 |
1 files changed, 100 insertions, 77 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index a23bdfcadd..175ff8cc49 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 @@ -5005,7 +5027,7 @@ void QImage::setColorSpace(const QColorSpace &colorSpace) return; if (d->colorSpace == colorSpace) return; - if (colorSpace.isValid() && !qt_compatibleColorModel(pixelFormat().colorModel(), colorSpace.colorModel())) + if (colorSpace.isValid() && !qt_compatibleColorModelSource(pixelFormat().colorModel(), colorSpace.colorModel())) return; detachMetadata(false); @@ -5035,7 +5057,7 @@ void QImage::convertToColorSpace(const QColorSpace &colorSpace) } if (d->colorSpace == colorSpace) return; - if (!qt_compatibleColorModel(pixelFormat().colorModel(), colorSpace.colorModel())) { + if (!qt_compatibleColorModelTarget(pixelFormat().colorModel(), colorSpace.colorModel(), colorSpace.transformModel())) { *this = convertedToColorSpace(colorSpace); return; } @@ -5066,7 +5088,7 @@ void QImage::convertToColorSpace(const QColorSpace &colorSpace, QImage::Format f qWarning() << "QImage::convertToColorSpace: Output colorspace is not valid"; return; } - if (!qt_compatibleColorModel(toPixelFormat(format).colorModel(), colorSpace.colorModel())) { + if (!qt_compatibleColorModelTarget(toPixelFormat(format).colorModel(), colorSpace.colorModel(), colorSpace.transformModel())) { qWarning() << "QImage::convertToColorSpace: Color space is not compatible with format"; return; } @@ -5126,7 +5148,7 @@ QImage QImage::convertedToColorSpace(const QColorSpace &colorSpace, QImage::Form qWarning() << "QImage::convertedToColorSpace: Output colorspace is not valid"; return QImage(); } - if (!qt_compatibleColorModel(toPixelFormat(format).colorModel(), colorSpace.colorModel())) { + if (!qt_compatibleColorModelTarget(toPixelFormat(format).colorModel(), colorSpace.colorModel(), colorSpace.transformModel())) { qWarning() << "QImage::convertedToColorSpace: Color space is not compatible with format"; return QImage(); } @@ -5159,8 +5181,9 @@ void QImage::applyColorTransform(const QColorTransform &transform) if (transform.isIdentity()) return; - if (!qt_compatibleColorModel(pixelFormat().colorModel(), QColorTransformPrivate::get(transform)->colorSpaceIn->colorModel) || - !qt_compatibleColorModel(pixelFormat().colorModel(), QColorTransformPrivate::get(transform)->colorSpaceOut->colorModel)) { + if (!qt_compatibleColorModelSource(pixelFormat().colorModel(), QColorTransformPrivate::get(transform)->colorSpaceIn->colorModel) || + !qt_compatibleColorModelTarget(pixelFormat().colorModel(), QColorTransformPrivate::get(transform)->colorSpaceOut->colorModel, + QColorTransformPrivate::get(transform)->colorSpaceOut->transformModel)) { qWarning() << "QImage::applyColorTransform can not apply format switching transform without switching format"; return; } @@ -5220,14 +5243,14 @@ void QImage::applyColorTransform(const QColorTransform &transform) transformSegment = [&](int yStart, int yEnd) { for (int y = yStart; y < yEnd; ++y) { uint8_t *scanline = reinterpret_cast<uint8_t *>(d->data + y * d->bytes_per_line); - QColorTransformPrivate::get(transform)->applyGray(scanline, scanline, width(), flags); + QColorTransformPrivate::get(transform)->apply(scanline, scanline, width(), flags); } }; } else if (format() == Format_Grayscale16) { transformSegment = [&](int yStart, int yEnd) { for (int y = yStart; y < yEnd; ++y) { uint16_t *scanline = reinterpret_cast<uint16_t *>(d->data + y * d->bytes_per_line); - QColorTransformPrivate::get(transform)->applyGray(scanline, scanline, width(), flags); + QColorTransformPrivate::get(transform)->apply(scanline, scanline, width(), flags); } }; } else if (qt_fpColorPrecision(format())) { @@ -5321,15 +5344,15 @@ QImage QImage::colorTransformed(const QColorTransform &transform) const & if (transform.isIdentity()) return *this; - QColorSpace::ColorModel inColorModel = QColorTransformPrivate::get(transform)->colorSpaceIn->colorModel; - QColorSpace::ColorModel outColorModel = QColorTransformPrivate::get(transform)->colorSpaceOut->colorModel; - if (!qt_compatibleColorModel(pixelFormat().colorModel(), inColorModel)) { + const QColorSpacePrivate *inColorSpace = QColorTransformPrivate::get(transform)->colorSpaceIn.constData(); + const QColorSpacePrivate *outColorSpace = QColorTransformPrivate::get(transform)->colorSpaceOut.constData(); + if (!qt_compatibleColorModelSource(pixelFormat().colorModel(), inColorSpace->colorModel)) { qWarning() << "QImage::colorTransformed: Invalid input color space for transform"; return QImage(); } - if (!qt_compatibleColorModel(pixelFormat().colorModel(), outColorModel)) { + if (!qt_compatibleColorModelTarget(pixelFormat().colorModel(), outColorSpace->colorModel, outColorSpace->transformModel)) { // All model switching transforms are opaque in at least one end. - switch (outColorModel) { + switch (outColorSpace->colorModel) { case QColorSpace::ColorModel::Rgb: return colorTransformed(transform, qt_highColorPrecision(format(), true) ? QImage::Format_RGBX64 : QImage::Format_RGB32); case QColorSpace::ColorModel::Gray: @@ -5408,13 +5431,13 @@ QImage QImage::colorTransformed(const QColorTransform &transform, QImage::Format if (transform.isIdentity()) return convertedTo(toFormat, flags); - QColorSpace::ColorModel inColorModel = QColorTransformPrivate::get(transform)->colorSpaceIn->colorModel; - QColorSpace::ColorModel outColorModel = QColorTransformPrivate::get(transform)->colorSpaceOut->colorModel; - if (!qt_compatibleColorModel(pixelFormat().colorModel(), inColorModel)) { + const QColorSpacePrivate *inColorSpace = QColorTransformPrivate::get(transform)->colorSpaceIn.constData(); + const QColorSpacePrivate *outColorSpace = QColorTransformPrivate::get(transform)->colorSpaceOut.constData(); + if (!qt_compatibleColorModelSource(pixelFormat().colorModel(), inColorSpace->colorModel)) { qWarning() << "QImage::colorTransformed: Invalid input color space for transform"; return QImage(); } - if (!qt_compatibleColorModel(toPixelFormat(toFormat).colorModel(), outColorModel)) { + if (!qt_compatibleColorModelTarget(toPixelFormat(toFormat).colorModel(), outColorSpace->colorModel, outColorSpace->transformModel)) { qWarning() << "QImage::colorTransformed: Invalid output color space for transform"; return QImage(); } @@ -5511,7 +5534,7 @@ QImage QImage::colorTransformed(const QColorTransform &transform, QImage::Format for (int y = yStart; y < yEnd; ++y) { const quint8 *in_scanline = reinterpret_cast<const quint8 *>(d->data + y * d->bytes_per_line); QRgb *out_scanline = reinterpret_cast<QRgb *>(toImage.d->data + y * toImage.bytesPerLine()); - QColorTransformPrivate::get(transform)->applyGray(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); + QColorTransformPrivate::get(transform)->apply(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); } }; } else { @@ -5519,7 +5542,7 @@ QImage QImage::colorTransformed(const QColorTransform &transform, QImage::Format for (int y = yStart; y < yEnd; ++y) { const quint16 *in_scanline = reinterpret_cast<const quint16 *>(d->data + y * d->bytes_per_line); QRgba64 *out_scanline = reinterpret_cast<QRgba64 *>(toImage.d->data + y * toImage.bytesPerLine()); - QColorTransformPrivate::get(transform)->applyGray(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); + QColorTransformPrivate::get(transform)->apply(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); } }; } @@ -5530,7 +5553,7 @@ QImage QImage::colorTransformed(const QColorTransform &transform, QImage::Format for (int y = yStart; y < yEnd; ++y) { const quint8 *in_scanline = reinterpret_cast<const quint8 *>(d->data + y * d->bytes_per_line); QCmyk32 *out_scanline = reinterpret_cast<QCmyk32 *>(toImage.d->data + y * toImage.bytesPerLine()); - QColorTransformPrivate::get(transform)->applyGray(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); + QColorTransformPrivate::get(transform)->apply(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); } }; } else { @@ -5538,7 +5561,7 @@ QImage QImage::colorTransformed(const QColorTransform &transform, QImage::Format for (int y = yStart; y < yEnd; ++y) { const quint16 *in_scanline = reinterpret_cast<const quint16 *>(d->data + y * d->bytes_per_line); QCmyk32 *out_scanline = reinterpret_cast<QCmyk32 *>(toImage.d->data + y * toImage.bytesPerLine()); - QColorTransformPrivate::get(transform)->applyGray(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); + QColorTransformPrivate::get(transform)->apply(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); } }; } @@ -5550,7 +5573,7 @@ QImage QImage::colorTransformed(const QColorTransform &transform, QImage::Format for (int y = yStart; y < yEnd; ++y) { const QRgb *in_scanline = reinterpret_cast<const QRgb *>(fromImage.constBits() + y * fromImage.bytesPerLine()); quint8 *out_scanline = reinterpret_cast<quint8 *>(toImage.d->data + y * toImage.bytesPerLine()); - QColorTransformPrivate::get(transform)->applyReturnGray(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); + QColorTransformPrivate::get(transform)->apply(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); } }; } else { @@ -5559,7 +5582,7 @@ QImage QImage::colorTransformed(const QColorTransform &transform, QImage::Format for (int y = yStart; y < yEnd; ++y) { const QRgba64 *in_scanline = reinterpret_cast<const QRgba64 *>(fromImage.constBits() + y * fromImage.bytesPerLine()); quint16 *out_scanline = reinterpret_cast<quint16 *>(toImage.d->data + y * toImage.bytesPerLine()); - QColorTransformPrivate::get(transform)->applyReturnGray(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); + QColorTransformPrivate::get(transform)->apply(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); } }; } @@ -5570,7 +5593,7 @@ QImage QImage::colorTransformed(const QColorTransform &transform, QImage::Format for (int y = yStart; y < yEnd; ++y) { const QCmyk32 *in_scanline = reinterpret_cast<const QCmyk32 *>(fromImage.constBits() + y * fromImage.bytesPerLine()); quint8 *out_scanline = reinterpret_cast<quint8 *>(toImage.d->data + y * toImage.bytesPerLine()); - QColorTransformPrivate::get(transform)->applyReturnGray(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); + QColorTransformPrivate::get(transform)->apply(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); } }; } else { @@ -5578,7 +5601,7 @@ QImage QImage::colorTransformed(const QColorTransform &transform, QImage::Format for (int y = yStart; y < yEnd; ++y) { const QCmyk32 *in_scanline = reinterpret_cast<const QCmyk32 *>(fromImage.constBits() + y * fromImage.bytesPerLine()); quint16 *out_scanline = reinterpret_cast<quint16 *>(toImage.d->data + y * toImage.bytesPerLine()); - QColorTransformPrivate::get(transform)->applyReturnGray(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); + QColorTransformPrivate::get(transform)->apply(out_scanline, in_scanline, width(), QColorTransformPrivate::InputOpaque); } }; } @@ -5682,11 +5705,11 @@ QImage QImage::colorTransformed(const QColorTransform &transform, QImage::Format const quint8 *in_scanline = reinterpret_cast<const quint8 *>(fromImage.constBits() + y * fromImage.bytesPerLine()); if (tmpFormat == Format_Grayscale8) { quint8 *out_scanline = reinterpret_cast<quint8 *>(toImage.d->data + y * toImage.bytesPerLine()); - QColorTransformPrivate::get(transform)->applyGray(out_scanline, in_scanline, width(), transFlags); + QColorTransformPrivate::get(transform)->apply(out_scanline, in_scanline, width(), transFlags); } else { Q_ASSERT(tmpFormat == Format_Grayscale16); quint16 *out_scanline = reinterpret_cast<quint16 *>(toImage.d->data + y * toImage.bytesPerLine()); - QColorTransformPrivate::get(transform)->applyGray(out_scanline, in_scanline, width(), transFlags); + QColorTransformPrivate::get(transform)->apply(out_scanline, in_scanline, width(), transFlags); } } }; @@ -5695,7 +5718,7 @@ QImage QImage::colorTransformed(const QColorTransform &transform, QImage::Format for (int y = yStart; y < yEnd; ++y) { const quint16 *in_scanline = reinterpret_cast<const quint16 *>(fromImage.constBits() + y * fromImage.bytesPerLine()); quint16 *out_scanline = reinterpret_cast<quint16 *>(toImage.d->data + y * toImage.bytesPerLine()); - QColorTransformPrivate::get(transform)->applyGray(out_scanline, in_scanline, width(), transFlags); + QColorTransformPrivate::get(transform)->apply(out_scanline, in_scanline, width(), transFlags); } }; } else if (fromImage.format() == Format_CMYK8888) { @@ -5789,15 +5812,15 @@ QImage QImage::colorTransformed(const QColorTransform &transform) && if (!d) return QImage(); - QColorSpace::ColorModel inColorModel = QColorTransformPrivate::get(transform)->colorSpaceIn->colorModel; - QColorSpace::ColorModel outColorModel = QColorTransformPrivate::get(transform)->colorSpaceOut->colorModel; - if (!qt_compatibleColorModel(pixelFormat().colorModel(), inColorModel)) { + const QColorSpacePrivate *inColorSpace = QColorTransformPrivate::get(transform)->colorSpaceIn.constData(); + const QColorSpacePrivate *outColorSpace = QColorTransformPrivate::get(transform)->colorSpaceOut.constData(); + if (!qt_compatibleColorModelSource(pixelFormat().colorModel(), inColorSpace->colorModel)) { qWarning() << "QImage::colorTransformed: Invalid input color space for transform"; return QImage(); } - if (!qt_compatibleColorModel(pixelFormat().colorModel(), outColorModel)) { + if (!qt_compatibleColorModelTarget(pixelFormat().colorModel(), outColorSpace->colorModel, outColorSpace->transformModel)) { // There is currently no inplace conversion of both colorspace and format, so just use the normal version. - switch (outColorModel) { + switch (outColorSpace->colorModel) { case QColorSpace::ColorModel::Rgb: return colorTransformed(transform, qt_highColorPrecision(format(), true) ? QImage::Format_RGBX64 : QImage::Format_RGB32); case QColorSpace::ColorModel::Gray: |