summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qimage.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Copy image offset in copyMetadataAllan Sandfeld Jensen2024-04-181-4/+2
| | | | | | | | Making it be carried more consistently. Pick-to: 6.7 Change-Id: I8d2da1264a59febbd44bbcff798b647ec2813bb0 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Convert "(added in)" enum warnings to [since] syntaxAllan Sandfeld Jensen2024-04-181-30/+51
| | | | | | | | | | With the since syntax we can now mark since more standardized Pick-to: 6.7 Change-Id: I3c53010043a40e8887f1899cde2689ee80e530ae Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Jaishree Vyas <jaishree.vyas@qt.io>
* Add CMYK support to QColorSpaceAllan Sandfeld Jensen2024-04-121-25/+158
| | | | | | | | [ChangeLog][QtGui][QColorSpace] Support for CMYK color spaces has been added. Change-Id: I2c684dbeee8b97fc90ca4e2a892349a7fa465d06 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Add color space model, making gray color spaces explicitAllan Sandfeld Jensen2024-04-051-13/+503
| | | | | | | | | This also adds image conversion of both format and color space, which will also be required later for conversions to CMYK formats and color spaces. Change-Id: I578c0a010ffcdb4df4cf9080c0621fac8bc342bf Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QImage: remove the last mentions of Format_CMYK32Giuseppe D'Angelo2024-04-051-1/+0
| | | | | Change-Id: I8ef63d7f3f14f16111a7e45e07734c10e448984c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Port QImage::Format_CMYK32 to CMYK8888Giuseppe D'Angelo2024-04-041-5/+6
| | | | | | | | | | | | Follow the established convention that byte-oriented image formats have the "8888" suffix, not "32". The old enum name is temporarily left to help port other submodules. This work has been kindly sponsored by the QGIS project (https://qgis.org/). Change-Id: I4b6f10cb22312b614cb9cf4b0ac439907276c538 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* GUI: add CMYK painting supportGiuseppe D'Angelo2024-04-031-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 <allan.jensen@qt.io>
* Add QColorSpace::isValidTargetAllan Sandfeld Jensen2024-03-271-2/+8
| | | | | | | | To indicate color spaces that can not be used as a target, but only as a source. Change-Id: Iae79e3533599c112872d171a2f45178029be89dc Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Copy color table in QImage::transform paint pathAllan Sandfeld Jensen2023-12-141-1/+8
| | | | | | | | | A copy without pixel ratio was made, but color table not set. Pick-to: 6.7 6.6 6.5 6.2 Fixes: QTBUG-119902 Change-Id: I328f3faa70d7a1263061cbe51921999393e30801 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Fix smooth scaling of Format_Mono and Format_MonoLSBJoni Poikelin2023-10-261-4/+14
| | | | | | | Fixes: QTBUG-117713 Pick-to: 6.6 6.5 6.2 Change-Id: I2fb071a4d2229da50dfacb0a92c51c3e4ea57a74 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* qt_getImageTextFromDescription: use tokenize instead of splitAnton Kudryavtsev2023-09-061-2/+1
| | | | | | | to avoid creation of tmp list Change-Id: I53917263fe9e904596ccc5af6a72bb3d906b21dc Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Doc: Delete links to removed examplesAndreas Eliasson2023-08-181-2/+2
| | | | | | | | | | The examples have been removed as part of the examples revamp project. This patch resolves a number of qdoc warnings. Pick-to: 6.6 6.5 Change-Id: Ie3d2f5637136c631d7e9f7a8ffd93baea52f77d8 Reviewed-by: Kai Köhne <kai.koehne@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Replace {add,sub,mul}_overload with q{Add,Sub,Mul}OverloadMarc Mutz2023-06-121-1/+1
| | | | | | | | | | | | | | | | | | | These APIs started out as private APIs in qnumeric_p.h, but have since been made pseudo-public in qnumeric.h. The qnumeric_p.h versions just forward to the qnumeric.h ones, so just use the latter. This is in preparation of removing the {add,sub,mul}_overflow versions, which, despite being defined in the unnamed namespace, don't sport the q prefix, so potentially clash with global symbols. The change is a simple textual search and replace, manually excluding qnumeric_p.h. Picking to 6.5 to avoid cherry-pick conflicts going forward. Pick-to: 6.6 6.5 Change-Id: Ic0f7c92f7c47923317109e8a9dc06fa66bdff2c2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QImage: when saving fails, print the writer's error stringVolker Hilsheimer2023-04-111-2/+7
| | | | | | | | | | | | In debug builds, don't fail silently in QImage::save, but emit the error string of the QImageWriter to the warning stream so that developers have a chance to know what's going on. Task-number: QTBUG-103257 Task-number: QTBUG-41043 Pick-to: 6.5 Change-Id: I29718b1445d0c99a3b35d57b58ec915a503cd5f0 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Add special thread pool for Qt GuiAllan Sandfeld Jensen2023-02-251-3/+4
| | | | | | | | | To avoid gui slowdowns due to global pool being blocked. Fixes: QTBUG-109511 Pick-to: 6.5 6.4 6.2 Change-Id: I4e8d91e8fb0bd2e395072a082e992a3c5d3464ad Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Trace: Autogenerate metadata in qtgui moduleAntti Määttä2023-02-101-45/+2
| | | | | | | | Pick-to: 6.5 Change-Id: I300ecb9d25f0ecb7208c643704adf66bdf0a4b56 Reviewed-by: Antti Määttä <antti.maatta@qt.io> Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
* Trace: Use includes instead of forward declarationsAntti Määttä2023-02-101-3/+1
| | | | | | | | | | Some platforms do not work with forward declarations, mainly android. Pick-to: 6.5 Change-Id: Ie34a30ecb8554d77c1bea4b65a752d63ba819af9 Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io> Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io> Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
* Add tracing metadata to QEvent and QImageFormatAntti Määttä2023-01-131-5/+51
| | | | | | | | | | | Modify qtcore and qtwidgets to use the new tracing metadata features. This allows showing the event types and image formats used in traces as text instead of just numbers. Task-number: QTBUG-106399 Pick-to: 6.5 Change-Id: I267d03a696dc95e8b1d36657d7339dd09d92de3b Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
* Add tracepointgen tool and convert qtgui to use itAntti Määttä2023-01-131-9/+22
| | | | | | | | | | | | | | | | | | | | | Allows automatically generating tracepoint files by scanning source files for instrumentation macros. This makes it easier to add tracepoint support to modules and also ensures that the tracepoint files do not get out of sync with the functions they are tracing. Q_TRACE_INSTRUMENT generates entry/exit tracespoints for a function it is set. Q_TRACE_PARAM_REPLACE is used to change a function parameter for these functions to convert it to supported parameter type. Q_TRACE_POINT can be used to create a standalone tracepoint. Q_TRACE_PREFIX can be used to add prefix for generated tracing backend for example to add includes for types used in the trace points.. Task-number: QTBUG-107238 Pick-to: 6.5 Change-Id: Ib395b80838434ceb72683dac0545ca20c4d09455 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
* QtGui: fix build with GCC 13's support for FP16Thiago Macieira2023-01-111-6/+6
| | | | | | | | | | | Conversion must be explicit from float, but doesn't need to be from int. qimage.cpp:1915:33: error: converting to ‘qfloat16::NativeType’ {aka ‘_Float16’} from ‘float’ with greater conversion rank [-Werror] Pick-to: 6.5 Change-Id: Ide4dbd0777a44ed0870efffd17390a0e86f1fd7e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Handle allocation failure in QImage rotate 90/180/270 functionsEirik Aavitsland2022-11-041-0/+6
| | | | | | | Fixes: QTBUG-108186 Pick-to: 6.4 6.2 5.15 Change-Id: I354e75d9f063cdea0340b84e9585a61651a7c70f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Doc: Add missing since 6.2 to QImage and QPixmapYuhang Zhao2022-09-071-3/+5
| | | | | | | | | | | | The deviceIndependentSize() function of QImage and QPixmap was added in Qt 6.2 but their docs are missing this information, so add them. And it seems the QImage docs were copied from QPixmap, so it still reference to pixmap, not image, fix it as a drive-by. Pick-to: 6.4 6.3 6.2 Change-Id: Ic3d0a2019b5e9b89bd8723d994d7ae54f2cb5257 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Apply Q_CONSTINIT where beneficialSona Kurazyan2022-09-011-1/+1
| | | | | | | | | | Applied Q_CONSTINIT to variables with static storage duration, but skipped the POD types with core constant initializers. Task-number: QTBUG-100486 Change-Id: Iaabf824e9cb0f29a405a149912200d4e4b3573c1 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Trace QImage::Format as int in QImageData::create()Shawn Rutledge2022-06-141-1/+1
| | | | | | | | | | Traces can contain only a few types; for now, enums have to be converted to int. Amends 6d323c0b221a3b127d80e338a42306cc34bc4d40 Task-number: QTBUG-102862 Change-Id: If129d03b13e723350bac987c6e35d471aa6c17e2 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Rafael Roquetto <rafael.roquetto@qt.io>
* Fix misuses of 0.9999 constantAllan Sandfeld Jensen2022-06-021-7/+2
| | | | | | | | | Replace it with floor and round. It appears the old behavior was to work around combining ceil with inaccurate FP, but it doesn't appear this hacky ceil is needed. Change-Id: I5c16ec0fa4916e17198a733c46937fde53f2ddb5 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Do metadata detach simpler than full detachAllan Sandfeld Jensen2022-06-011-14/+36
| | | | | | | | | Avoid a full data detach when only metadata changes. This paradigm was already used one place, and made generic. Fixes: QTBUG-81674 Change-Id: I605253babc6ad9fc130e19e8cef3812690933ac5 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Expand QColorTransformAllan Sandfeld Jensen2022-05-261-4/+41
| | | | | | | | | | Add comparison operators and an isIdentity() method to detect (1-1) transforms. [ChangeLog][QtGui] Added QColorTransform::isIdentity() method. Added QImage::colorTransformed() transitive method. Change-Id: I5fbcd14e75f2179e43e94e8c5f42cd0a5600790b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Add floating point color space conversionsAllan Sandfeld Jensen2022-05-141-9/+23
| | | | | | | | | | This allows color space conversions that produces values outside the 0.0->1.0 range, which is one of the intended functions of the floating point image formats. Change-Id: I63b37b0f6934d4382edafb4709486c785a637c67 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QtGui: includemocsMarc Mutz2022-04-291-0/+2
| | | | | | | | | | | Including moc files directly into their classes' TU tends to improve codegen and enables extended compiler warnings, e.g. about unused private functions or fields. Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-102886 Change-Id: I1945741794c25679a9d94c0d68c8642e2c823502 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QtGui: use _L1 for for creating Latin-1 string literalsSona Kurazyan2022-04-281-2/+4
| | | | | | Task-number: QTBUG-98434 Change-Id: Idcb71c1d27125333a53b6bdd3e1af0d4c66617fa Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QtGui: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-131-2/+2
| | | | | | | | | Required for porting away from QLatin1Char/QLatin1String in scope of QTBUG-98434. Change-Id: I308d86cefcbfd126929b68f9a853d420840c965f Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Detach for colortransforms of indexed formatsAllan Sandfeld Jensen2022-04-061-3/+5
| | | | | | | | | | We were triggering detach during the transform, but the short-cut for indexed formats wasn't triggering that. Instead make the detach explicit and avoid it during the loop. Pick-to: 6.3 6.2 5.15 Change-Id: I0f12b7f93841342a0770ce3d3c78f26ad19d8dac Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QImage::operator==: Also compare the image colorspaceAlbert Astals Cid2022-03-181-1/+1
| | | | | | Pick-to: 6.3 6.2 Change-Id: I4cb86d32492876791fe852f8c3123b7d4a69a5bd Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Fix deprecated uses of QScopedPointerMårten Nordheim2022-03-081-2/+4
| | | | | | | | | By changing it to unique_ptr. Pick-to: 6.2 6.3 Change-Id: I91abb69445b537d4c95983ae735341882352b29d Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Draw extended RGB solid colorsAllan Sandfeld Jensen2022-01-121-0/+25
| | | | | | | Pass extended RGB colors through the paint engine. Change-Id: I2e212cd4c76aaa65439746352c0da2b9db4a506d Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Increment reference count when restoring referenceAllan Sandfeld Jensen2021-11-181-0/+1
| | | | | | | | | | Otherwise the count will be wrong after an out of memory failure in reinterpretAsFormat. Pick-to: 6.2 5.15 Fixes: QTBUG-98377 Change-Id: Ice51d47a6db9277126a5c7337e14aaf5ddee3a10 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* gui: Fix typos in documentationJonas Kvinge2021-10-121-2/+2
| | | | | | Pick-to: 5.15 6.2 Change-Id: I533f5a55cd0cd60a76990b552d7dab51a301ac1c Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* gui: Fix typos in source code commentsJonas Kvinge2021-10-121-1/+1
| | | | | | Pick-to: 5.15 6.2 Change-Id: Ie53e5542a8f93856470982939ecd8ec90b323d69 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Preserve QImage metadata when converting format with color tableEirik Aavitsland2021-09-281-1/+1
| | | | | | | | | | Unlike the other conversion functions, convertWithPalette() did not call copyMetadata(). Fixes: QTBUG-96926 Pick-to: 6.2 5.15 Change-Id: I2b171cec16bc5a90d33e80d6fe178c650ed3fe36 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Remove unused internal flag in QImageEirik Aavitsland2021-08-131-8/+3
| | | | | | | | | | The "locked" flag was only added for a particular use in the Freetype font engine in 070d9c00c488a5ee6811f04170cf488ead79bf80,but that usage was refactored away long ago in afb326f07109da0035112e6f56e683e37b8a5d72. Pick-to: 6.2 Change-Id: I7347c91f49ba59041f6ff35bd5a6b537d6c704d4 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Rename QRgbaF to QRgbaFloat and assert the compatible typesAllan Sandfeld Jensen2021-07-051-17/+17
| | | | | | | Pick-to: 6.2 Change-Id: I2404fdfd43d3b4553760ad2f605175121cd31446 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Add shortcut for QImage::applyColorTransform on indexed imagesAllan Sandfeld Jensen2021-06-101-0/+7
| | | | | | | | This also helps preserve bitmaps. Pick-to: 6.2 Change-Id: I8aa1ea63dc7dfb948a9c8821f0fe1ddd07f1bc3a Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Add load/fromdata() overloads taking QByteArrayView to QImageEirik Aavitsland2021-06-021-14/+39
| | | | | | | | | | | | | | Handy when one has the data buffer to be read in a QBAV. This also fixes an issue and compiler warning about passing a qsizetype data length value as an int, and makes it possible to pass a qsizetype-size length without going through QByteArray. Makes the QByteArray overload redundant. Change-Id: Iba8825cf0fd8003fb2eac5b1d30a61ec91b85ceb Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Introduce float QImage formats and renderingAllan Sandfeld Jensen2021-05-261-10/+267
| | | | | | | | | Useful for some HDR representations and HDR rendering. Change-Id: If6e8a661faa3d2afdf17b6ed4d8ff5c5b2aeb30e Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Disable spurious MSVC warning C4273 in Qt Gui, Qt OpenGLKai Köhne2021-05-031-0/+5
| | | | | | | | | | | | For optimized/release builds, cl 19.28 produces some false positive "potential divide by 0" warnings even for code where no valid code path can lead to such a division. Fixes: QTBUG-92940 Pick-to: 6.1 Change-Id: I461f9104d7b9dc2d74839bf30bebb2b9d4cf2db3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Test incoming formats more throuroughlyAllan Sandfeld Jensen2021-03-231-6/+9
| | | | | | | Just to protect against invalid data in d->format. Change-Id: I5e7cc04d5d8e42bdcb0edd2ab5fa34a08b96b6a8 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Fix alpha handling of QImage::setPixelAllan Sandfeld Jensen2021-03-221-2/+9
| | | | | | | | | | It was treated differently depending on format, made it consistently behave the same for all formats (following the behavior of the primary formats). Pick-to: 6.1 6.0 5.15 Change-Id: Ie24e19957d076fdf3ebd333074e26ede187489eb Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Add deviceIndependentSize() to QPixmap and QImageMorten Johan Sørvig2021-03-081-2/+18
| | | | | | | | | | This function returns the size in device independent pixels, and should be used when calculating user interface sizes. Change-Id: I528123f962595a3da42438ca560289a29aca4917 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* And fix handling and test of QImage::fill(uint) as wellAllan Sandfeld Jensen2021-02-251-0/+4
| | | | | | | | | Only RGB444 and RGB666 were treated slighlty different from the rest, but the test had a few additional mistakes. Pick-to: 6.1 6.0 5.15 Change-Id: I4728b4036affedfffce8bca5c1e7be3869344fbe Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>