summaryrefslogtreecommitdiffstats
path: root/src/gui/image
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* QIconLoader: code tidiesGiuseppe D'Angelo2021-09-182-43/+32
| | | | | | | | | | | | | | | | | | Turn QThemeIconEntries into an owning container (std::vector of unique_ptr), so that code using QThemeIconInfo doesn't have to manage ownership (and forget to do so, and cause bugs like QTBUG-93050). The fallout is mostly on isEmpty() vs empty(); as drive-by fixes: * use auto; * use make_unique (no raw news); * turn a few indexed loops into range-based ones; * streamline an if-else-if chain; * turn a !(a == b) condition into a != b. Change-Id: Ie3ac9de57c80ed3184ec0d15c847f81306ef48ca Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qt_pixmap_thread_test(): Simplify logic, merge warningsSze Howe Koh2021-09-061-12/+6
| | | | | | Pick-to: 6.2 Change-Id: I0c413c14d124bafbd6b2bd94d7a128e19ed83ade Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QPixmap: Fix crash if created without gui app in secondary threadSze Howe Koh2021-09-041-1/+1
| | | | | | | | | | | | | The thread checking in in_pixmap_thread_test() is only safe, and only makes sense, if we have a QGuiApplication. If we only have QCoreApplication, only null QPixmaps may be created anyway, so threading makes no difference. Fixes: QTBUG-95358 Pick-to: 6.2 Change-Id: I93c983a3d6c271b0a19dfd0384862fc151459029 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
* When clearing QPixmapCache, stop its flushing timerEirik Aavitsland2021-09-011-0/+5
| | | | | | | | | | | | | | No need for timer event to reduce cache size when it is already empty. May also avoid the "Timers cannot be stopped from another thread" warning at exit, if the global cache object is then deleted by another thread. Fixes: QTBUG-96101 Pick-to: 6.2 5.15 Change-Id: Id1aeecfbb43a25a887ebd5cc7242749a74290bb0 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix warning about loop variable creating a copyTor Arne Vestbø2021-08-241-1/+1
| | | | | | | | | | | qxpmhandler.cpp:1162:21: warning: loop variable '[color, index]' of type 'const std::__1::pair<const unsigned int, int>' creates a copy from type 'const std::__1::pair<const unsigned int, int>' [-Wrange-loop-analysis] for (const auto [color, index] : colorMap) ^ Change-Id: Ifabf1c569efdcd929859227d860f4598250ba5bd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* qpnghandler: Only assume we're past the input size if it returns a sizeAlbert Astals Cid2021-08-191-1/+1
| | | | | | | | | | Size 0 is a "valid" answer for QIODevice implementations so we need to make sure that we only enter the "try to workaround broken files" if we know there is a size, otherwise the first read of length 4 that libpng does breaks everything. Change-Id: I1e396abd206ff90edae4372726f1d82d5d41ccf3 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Remove unused internal flag in QImageEirik Aavitsland2021-08-132-9/+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>
* QXpmHandler: clean up write_xpm_image: cut out the QBA middle-manMarc Mutz2021-08-061-4/+3
| | | | | | | | | | | | Instead of appending to a QByteArray and then streaming that one, just stream the components of a line directly. QTextStream's op<<(const char*) is not subject to QT_NO_CAST_FROM_ASCII, etc., so can be used unconditionally. Change-Id: Idd97a75a1b5b939de7176d40880a2f328d01927d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QXpmHandler: actually limit characters-per-pixel to fourMarc Mutz2021-08-061-2/+5
| | | | | | | | | | | | | | | | | | | The following code assumed, and all comments indicated, that the cpp variable was limited to a max of 4. Yet, as coded, cpp could be five, in which case the XPM would be corrupt, as the header suggested five characters-per-pixel while the data was formatted in only four. Add a warning and error out when we encounter this situation. [ChangeLog][QtGui][QImage] Instead of writing a corrupt file, rejects to write XPM files with more than 64^4 colors (more than four characters per pixel) now. Pick-to: 6.2 6.1 5.15 5.12 Change-Id: I458873cf7d179ab2e2dacd4c17dc837d640591a9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QXpmHandler: clean up write_xpm_image: use conventional pointer arithmeticMarc Mutz2021-08-051-6/+3
| | | | | | | | | | | | | | ... instead of *(array + index). Also fix a pointless cast from QRgb to int which the next line implicitly undoes (because colorMap has QRgb as key, not int) and get rid of the local variables that facilitated said fallacy in the first place. Change-Id: I71a92822ee2404646f6fb5533e40252f38e6b21f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QXpmHandler: clean up write_xpm_image: scope variables betterMarc Mutz2021-08-051-5/+4
| | | | | | | ... and fix spacing around operators and after flow-control keywords. Change-Id: Iefaa03074536d13a655c91fb42aef6aa96c2665b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QXpmHandler: avoid double-lookupMarc Mutz2021-08-051-9/+14
| | | | | | | | | | | | | | | | The code used the if (!contains()) { insert() } anti-pattern, necessitated by Qt's deviation from the STL of allowing insert() to overwrite an existing entry, causing two lookups of the same key. Since QMap these days is a wrapper around std::map, fix by using the real thing (a std::map) instead, which sports the non-broken insert() semantics already, avoiding the need to play tricks like detecting a size increase in order to find whether an insertion took place. It also simplifies the loop later on, and we can transparently use pmr, when available. Change-Id: Iedd8d5691514a7705a55c27376446304b20af071 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QXpmHandler: clean up write_xpm_image: make w,h constMarc Mutz2021-08-051-1/+3
| | | | | | | ... and use one variable definition per line. Change-Id: Ie8e6d6fb9e570cf715ab0b39c78d677f1e5a19a7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QXpmHandler: fix re-entrancy bug in xpm_color_nameMarc Mutz2021-08-051-13/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | The xpm_color_name() function returned a pointer to a function-static buffer. This is infamously non-reentrant, and an actual problem, because we explicitly allow QImage operations (incl. saving to an .xpm) from non-GUI-threads. Fix by using the CSS pattern (Caller-Supplied Storage; also used in the QAnyStringView(char32_t) and QAnyStringView(QStringBuilder) ctors) to force the caller to allocate storage in its own stack frame. As a consequence, we re-gain re-entrancy, but the returned pointer is now only valid until the end of the full-expression, which necessitated simplifying one caller (sorry!). To see why said simplification is valid, observe that xpm_color_name() writes a (now-explicit) NUL into returnable[cpp] and the old code read max(cpp, 4) characters from xpm_color_name()'s result. NB: cpp can be 5, even though the code comments say otherwise! :( [ChangeLog][QtGui][QImage] Fixed a race condition when concurrently writing .xpm files. Pick-to: 6.2 6.1 5.15 5.12 Change-Id: I36d7173d53839a52f5cdf58324474c1b32c71f33 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Doc: Ensure deprecated APIs in Gui are documented as suchNico Vertriest2021-07-262-10/+6
| | | | | | | | | | | Added missing #if-ery and deprecation macros to a QFont constructor that was only documented as deprecated. Fixes: QTBUG-94521 Fixes: QTBUG-95310 Pick-to: 6.2 6.1 Change-Id: I3d0418a3f7dca191a9068cc22627fe4deb7c53c5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Improve support for saving QImage to QSaveFileEirik Aavitsland2021-07-141-5/+5
| | | | | | | | | | | | When saving to a QIODevice, QImage and QImageWriter will automatically deduct the file format from the filename if it determines that the device is a QFile. That did not work for a QSaveFile device. Fix by using the common ancestor, QFileDevice, in the implementation. Fixes: QTBUG-89022 Pick-to: 6.2 Change-Id: Ie01d80df4f29ca0d4ff30bf7e1b77605293c070e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Rename QRgbaF to QRgbaFloat and assert the compatible typesAllan Sandfeld Jensen2021-07-052-31/+31
| | | | | | | Pick-to: 6.2 Change-Id: I2404fdfd43d3b4553760ad2f605175121cd31446 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Fix reading gamma from PNGs without ICC profileAllan Sandfeld Jensen2021-06-111-2/+2
| | | | | | | | | | The decoding of PNG_INFO_gAMA to QColorSpace was incorrect, the PNG gamma is the inverse of the gamma value we use. We revert it everywhere else, just not here. Pick-to: 6.2 5.15 Change-Id: Ic0ae1963b2dde3004cac8a6430ddaf99e7096915 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@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-022-20/+48
| | | | | | | | | | | | | | 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-264-14/+543
| | | | | | | | | 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>
* Doc: Use \deprecated instead of \obsoletePaul Wicking2021-05-262-3/+3
| | | | | | Task-number: QTBUG-93990 Change-Id: I4e512354a49dde6678ca89cabc56bc76ba666bb3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Correct RGB to Grayscale conversionAllan Sandfeld Jensen2021-05-211-21/+152
| | | | | | | | | | | The existing conversions weren't handling gamma correctly and used an ad-hoc definition of gray instead of based on true luminance. [ChangeLog][QtGui] RGB conversions to grayscale formats are now gamma-corrected and produce color-space luminance values Change-Id: I88ab870c8f5e502ddb053e6a14a75102239a26f2 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove Qt6 switches from QtGuiAllan Sandfeld Jensen2021-05-052-7/+0
| | | | | | | Removing now dead code Change-Id: I021539da6517fdb8443f8ae9431fc172b7910cfc Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Disable spurious MSVC warning C4273 in Qt Gui, Qt OpenGLKai Köhne2021-05-032-0/+10
| | | | | | | | | | | | 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>
* Avoid adding null-objects to the icon cacheFan PengCheng2021-04-231-3/+3
| | | | | | | | | | When we can't get the icon for the first time, we would use the data in the cache later, and we will never get the new icon when the system theme is updated while the application is running. Pick-to: 6.1 Change-Id: I839ad9983918561a1dc6bc842f85477bba53f64a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Cleanup leftover QWSTasuku Suzuki2021-04-141-1/+0
| | | | | | | QWS is replaced with QPA in Qt5 Change-Id: Iccec38e55ae23a27ebecd8010e1df7bba8aa5a33 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Fix qdoc warningVolker Hilsheimer2021-04-131-1/+1
| | | | | | | | | QPixmap doesn't have a devicePixelSize() method, but deviceIndependentSize is a relevant method here. Change-Id: Ie71e6cc88534792a896ea17ec37b1b9737c2f986 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Nico Vertriest <nico.vertriest@qt.io>
* Do not notify about property changes if the value hasn't changedSona Kurazyan2021-04-071-2/+6
| | | | | | | | | | | | After 2ffb91ac592d69adf9458ac45074174537435918 we manually call notify() for QObjectCompatProperties. Currently we always call it when setting values to compat properties, even if the value hasn't actually changed. Fixed to call notify() only if the value is being changed. Task-number: QTBUG-85520 Change-Id: I385db84c4009c45406e204b96e0e37ce5fa8882b Reviewed-by: Andreas Buhr <andreas.buhr@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QObjectCompatProperty: Require explicit notifyFabian Kosmale2021-04-011-0/+1
| | | | | | | | | | For QObjectCompatProperty, which allows to do basically anything in its setter, it is actually easier to manually specify when the change should become visible. This is in line with manually writing emit calls in the old property system, and allows the preservation of class invariants. Change-Id: I585bd3f25d722ca3fd721ead85fe73dbee26c5f6 Reviewed-by: Ulf Hermann <ulf.hermann@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>
* QAbstractFileIconProvider: Fix compilation without feature mimetypeFabian Kosmale2021-03-212-0/+15
| | | | | Change-Id: I3aecc1ab97ed549511bc9a5cbc8eb780f5e9a4dd Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Doc: Fix various documentation issuesTopi Reinio2021-03-161-2/+2
| | | | | | | | | | - Document QIODeviceBase - Document QPointerEvent::points - Fix linking issues Task-number: QTBUG-90662 Change-Id: Ib123d5708953b22e01f95c82626b39a49fff95b2 Reviewed-by: Nico Vertriest <nico.vertriest@qt.io>
* Avoid undefined color values in corrupt xpm imageEirik Aavitsland2021-03-121-1/+1
| | | | | | | | Issue reported by Codechecker. Pick-to: 6.1 6.0 5.15 5.12 Change-Id: I1a5aa2203fb31e0ce3b630a11e450925aee81fb0 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QIcon::setIsMask: delete extra judgmentYang Yuyin2021-03-111-2/+1
| | | | | | | | | QIcon::detach can judgment if the d pointer is nullptr Pick-to: 6.1 Change-Id: I90fd5f50ed2565a5654b978c4603635e62677953 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Add deviceIndependentSize() to QPixmap and QImageMorten Johan Sørvig2021-03-084-3/+36
| | | | | | | | | | 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>
* Add QColorSpace::descriptionAllan Sandfeld Jensen2021-03-041-1/+1
| | | | | | | | | A way to read the description of the profile from ICC, or set one yourself. Change-Id: I68622e30ee209cac99c41f3df934712c3548c0de Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Reduce warnings from ICC parsingAllan Sandfeld Jensen2021-02-251-2/+2
| | | | | | | | | | Messages about Qt deficiencies reduced to info, and info set as the default message level. Pick-to: 6.1 6.0 5.15 Fixes: QTBUG-91401 Change-Id: Ia97438f08de5e0383e77631dca9b253b47ef8167 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QIcon::setIsMask: don't dereference nullptrVolker Hilsheimer2021-02-251-2/+2
| | | | | | | | | | | | | | QIcon::detach might result in the d pointer being nullptr, and other code tests for that condition and allocates the d pointer explicitly. Change the order of the tests in setIsMask as well, fix static analzyer warning 0a4723ca2d216ec8883a3d412aeded4c. Pick-to: 6.1 Change-Id: Idca12f230036362f13cbaee1ae4f0e5ce6726015 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@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>
* Improve QImage::fill(uint) documentationAllan Sandfeld Jensen2021-02-251-5/+5
| | | | | | | | | | Remove paragraph about long gone methods, and rephrase it as a note on corresponding getters. At the same time document 64-bit behavior as undefined. Pick-to: 6.1 Change-Id: I26ffd95040eb0aea30585aa0fa8526417b0ecc7a Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QAbstractFileIconProvider: Use platform theme iconsFriedemann Kleint2021-02-212-24/+111
| | | | | | | | Add code paths to use platform theme icons should icon themes fail. Task-number: QTBUG-66177 Change-Id: I9554637f5230b1f57faaeef6b2c04cf082271edb Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add scaledPixmap() overrideMorten Johan Sørvig2021-02-192-0/+7
| | | | | | | | | | | | | | | | | QAbstractFileIconEngine implements the QIconEngine interface and creates a new interface where subclasses override the filePixmap() function. QIconEngine subclasses must now also override scaledPixmap(); add implementation which forwards to filePixmap(). (The intermediate implementation in QPixmapIconEngine is not used by QAbstractFileIconEngine.) Pick-to: 6.1 Task-number: QTBUG-91104 Change-Id: I229e3a003ad0c3fff768eac7e75c59fe7145fcaa Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix QImage::fill with semi-transparent QColorAllan Sandfeld Jensen2021-02-121-11/+10
| | | | | | | | | A few formats were not treating the input QColor correctly. Fixed and added more exhaustive test. Pick-to: 6.1 6.0 5.15 Change-Id: I872aeeb45e518f9a34b4ac35642264821f9927f2 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Optimize RGBA64PM->RGBA64 for SSE4Allan Sandfeld Jensen2021-02-031-56/+0
| | | | | | | | And remove direct conversion to take advantage of both the SIMD, but also threading on all platforms. Change-Id: I782ae7c80e82b694e23abee28d69cecd0d28c32f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Optimize RGBA64->RGBA64PM for SSE2/AVX2Allan Sandfeld Jensen2021-02-031-46/+0
| | | | | | | | And remove the direct conversion so we can get both the SIMD optimization and threading applied. Change-Id: Id032ea91cc40c1cbf1c8a1da0386de35aa36cfb5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix nullptr dereference on out-of-memory conditionsAllan Sandfeld Jensen2021-02-021-0/+2
| | | | | | | Fixes two static analysis warnings. Change-Id: Id4644d1944e97c9c53d2268a9a71e5f6347d3946 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Segment qimage conversion block irrelevant of depthAllan Sandfeld Jensen2021-02-022-5/+5
| | | | | | | | Always try segments from 64k to 128k pixels, this matches qimagescale logic, and gives a one percent speedup locally. Change-Id: I3ef468eac9dca4b84f04850e970f3d15a4f16255 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>