diff options
author | Giuseppe D'Angelo <[email protected]> | 2023-10-18 18:42:01 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <[email protected]> | 2024-04-03 18:31:36 +0100 |
commit | 2a54229f90b5abcca04763834aa5b9d48e19131f (patch) | |
tree | e86a2b6dd440f2919c7a1f7dac1a8c71e75f3c14 /tests | |
parent | 9a92e26dcdb40215f2f5d187a09b6b2b73934809 (diff) |
GUI: add CMYK painting support
This commit adds a CMYK 8bpp format to QImage. The idea is to enable the
transport of CMYK images inside Qt, for instance to be loaded/saved from
files or painted on CMYK capable paint devices (e.g. PDF).
Also, rasterization support *from* a CMYK image is added (on top of a
RGB surface), as well as CMYK image scaling/conversion.
Conversion and rasterization between CMYK and RGB isn't particularly
optimized nor it honors any colorspaces yet. The overall idea is to
match 1:1 the existing behavior of CMYK QColor (which get naively
changed to RGB; there isn't colorspace support in QPainter yet).
There are no plans to add rasterization *towards* CMYK.
Image save/load in native CMYK formats will be added in future commits.
This work has been kindly sponsored by the QGIS project
(https://qgis.org/).
[ChangeLog][QtGui] Support for 8-bit CMYK images has been added.
Change-Id: I4b024cd4c15119c669b6ddd450418a9e425587f8
Reviewed-by: Allan Sandfeld Jensen <[email protected]>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/gui/image/qimage/tst_qimage.cpp | 18 | ||||
-rw-r--r-- | tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 10 | ||||
-rw-r--r-- | tests/baseline/shared/paintcommands.cpp | 1 |
3 files changed, 21 insertions, 8 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 59cc3a2129e..d7f70f29a10 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -321,7 +321,9 @@ static QLatin1String formatToString(QImage::Format format) return QLatin1String("RGBA32FPx4"); case QImage::Format_RGBA32FPx4_Premultiplied: return QLatin1String("RGBA32FPx4pm"); - default: + case QImage::Format_CMYK32: + return QLatin1String("CMYK32"); + case QImage::NImageFormats: break; }; Q_UNREACHABLE(); @@ -1507,6 +1509,8 @@ void tst_QImage::setPixelWithAlpha_data() continue; if (c == QImage::Format_Alpha8) continue; + if (c == QImage::Format_CMYK32) + continue; QTest::newRow(qPrintable(formatToString(QImage::Format(c)))) << QImage::Format(c); } } @@ -2568,7 +2572,8 @@ void tst_QImage::rgbSwapped_data() for (int i = QImage::Format_Indexed8; i < QImage::NImageFormats; ++i) { if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8 - || i == QImage::Format_Grayscale16) { + || i == QImage::Format_Grayscale16 + || i == QImage::Format_CMYK32) { continue; } QTest::addRow("%s", formatToString(QImage::Format(i)).data()) << QImage::Format(i); @@ -3050,13 +3055,15 @@ void tst_QImage::inplaceRgbConversion_data() for (int i = QImage::Format_RGB32; i < QImage::NImageFormats; ++i) { if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8 - || i == QImage::Format_Grayscale16) { + || i == QImage::Format_Grayscale16 + || i == QImage::Format_CMYK32) { continue; } for (int j = QImage::Format_RGB32; j < QImage::NImageFormats; ++j) { if (j == QImage::Format_Alpha8 || j == QImage::Format_Grayscale8 - || j == QImage::Format_Grayscale16) { + || j == QImage::Format_Grayscale16 + || j == QImage::Format_CMYK32) { continue; } if (i == j) @@ -3345,7 +3352,8 @@ void tst_QImage::invertPixelsRGB_data() for (int i = QImage::Format_RGB32; i < QImage::NImageFormats; ++i) { if (i == QImage::Format_Alpha8 || i == QImage::Format_Grayscale8 - || i == QImage::Format_Grayscale16) { + || i == QImage::Format_Grayscale16 + || i == QImage::Format_CMYK32) { continue; } QTest::addRow("%s", formatToString(QImage::Format(i)).data()) << QImage::Format(i); diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 15735aecf78..96f92105d16 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -2784,7 +2784,7 @@ void tst_QPainter::monoImages() for (int i = 1; i < QImage::NImageFormats; ++i) { for (int j = 0; j < numColorPairs; ++j) { const QImage::Format format = QImage::Format(i); - if (format == QImage::Format_Indexed8) + if (format == QImage::Format_Indexed8 || format == QImage::Format_CMYK32) continue; QImage img(2, 2, format); @@ -3554,9 +3554,13 @@ void tst_QPainter::drawImage_data() for (int srcFormat = QImage::Format_Mono; srcFormat < QImage::NImageFormats; ++srcFormat) { for (int dstFormat = QImage::Format_Mono; dstFormat < QImage::NImageFormats; ++dstFormat) { - // Indexed8 can't be painted to, and Alpha8 can't hold a color. - if (dstFormat == QImage::Format_Indexed8 || dstFormat == QImage::Format_Alpha8) + // Indexed8 and CMYK32 can't be painted to, and Alpha8 can't hold a color. + if (dstFormat == QImage::Format_Indexed8 || + dstFormat == QImage::Format_CMYK32 || + dstFormat == QImage::Format_Alpha8) { continue; + } + for (int odd_x = 0; odd_x <= 1; ++odd_x) { for (int odd_width = 0; odd_width <= 1; ++odd_width) { QTest::addRow("srcFormat %d, dstFormat %d, odd x: %d, odd width: %d", diff --git a/tests/baseline/shared/paintcommands.cpp b/tests/baseline/shared/paintcommands.cpp index a1d2b9e4972..20201b66b0d 100644 --- a/tests/baseline/shared/paintcommands.cpp +++ b/tests/baseline/shared/paintcommands.cpp @@ -173,6 +173,7 @@ const char *PaintCommands::imageFormatTable[] = { "RGBx32FPx4", "RGBA32FPx4", "RGBA32FPx4_Premultiplied", + "CMYK32", }; const char *PaintCommands::renderHintTable[] = { |