summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qimagereader.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QImageReader: use QFile::open return valueGiuseppe D'Angelo9 days1-3/+4
| | | | | | | | | The code was already OK because it used QFile::isOpen to check if open() succeeded or not. In preparation for making open() [[nodiscard]], refactor the code to just use its return value. Change-Id: Ibab86ca894103f01ff3b6084caedb3117ffb6c7e Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QImageReader: allow only one dimension to be used for scaledSizeVladimir Belyavsky2024-03-191-6/+26
| | | | | | | | | | | | | | | If only one dimension (width or height) of the scaled size is set by an user, let's try to calculate the second one, based on the image original size and maintaining the aspect ratio. [ChangeLog][QtGui][QImageReader] Allow only one dimension (width or height) to be set for the scaled size. In this case, the other will be calculated automatically based on the original image size and maintaining the aspect ratio. Task-number: QTBUG-115039 Change-Id: If1b13b1ead3cf788915c08bdb3ba8becd8bf8042 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QImageReader: Reduce code redundancyMike Chen2023-11-221-40/+25
| | | | | | | | | | | | | | | Refactor methods to simplify the code and improve readability. Replace calls to initHandler() and checks for handler support with calls to the supportsOption() method directly. Reduces code redundancy and improves the overall structure of the class. Additionally, use supportScaledSize, supportClipRect, and supportScaledClipRect to streamline the conditional logic and make it more understandable. Change-Id: I77d5dab8bcdd0b0eb6d7e9edcf87751aa03b80c7 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Image IO: increase the default allocation limitEirik Aavitsland2023-05-231-1/+3
| | | | | | | | | | | Time passes, Moore's law is working. As a drive-by, make the doc more informative. Fixes: QTBUG-113637 Pick-to: 6.5 Change-Id: Ic388b8850ace02c429d4d8175d31db86912d3afe Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Doc: Only list qt core classes in qt core io groupAndreas Eliasson2023-01-231-1/+0
| | | | | | | | | | | The group page for Qt core classes related to I/O include classes from other modules. Remove these classes from the group; it may confuse the reader. Fixes: QTBUG-110020 Pick-to: 6.5 6.4 6.2 5.15 Change-Id: If7df85523ce6b3aa09605bd89d9899ce308d2671 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
* Add tracepointgen tool and convert qtgui to use itAntti Määttä2023-01-131-0/+3
| | | | | | | | | | | | | | | | | | | | | 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>
* Fix deletion order also for QImageReader/Writer::setDevice()Eirik Aavitsland2023-01-111-2/+2
| | | | | | | | | | Avoid dangling or incorrect device pointer during handler destruction. This was recently fixed in the destructors, fixed here also for the setDevice() functions. Pick-to: 6.5 6.4 6.2 5.15 Change-Id: I85b64726cd88d2c8e63eee59d5b4f2ae488df61b Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Fix deletion order in QImageReader/Writer destructorsEirik Aavitsland2023-01-041-1/+1
| | | | | | | | | | The device would be deleted before the image format handler, and hence be a dangling pointer that could easily cause a crash if the handler or codec would access it on destruction, e.g. for cleanup. Pick-to: 6.5 6.4 6.2 5.15 Change-Id: I51d16b1feddc5945955ac75a2e8701233dba7b82 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@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>
* Replace remaining uses of deprecated _qs with _sSona Kurazyan2022-05-021-1/+2
| | | | | | Task-number: QTBUG-101408 Change-Id: I1fda67c07e948af5017f0b99b67f8c20d7052033 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QtGui: replace remaining uses of QLatin1String with QLatin1StringViewSona Kurazyan2022-04-281-2/+2
| | | | | | Task-number: QTBUG-98434 Change-Id: I98c27030c783f968cbf38dc966ce486dc366b302 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QtGui: stop using QLatin1Char constructor for creating char literalsSona Kurazyan2022-04-131-1/+1
| | | | | | | | | 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>
* QImageReader::read(): fetch filename onceShawn Rutledge2022-04-121-5/+3
| | | | | | | | | | | | The code in the Q_TRACE_ENABLED case was doing the same sort of qobject_cast that is done in the fileName() accessor; so it's both a code deduplication and an optimization to get the filename into a local variable once, and use it both for tracing and for the @Nx suffix check below. Task-number: QTBUG-100578 Change-Id: Id7bde4ddbab38e20694c09cc7b412fec091672de Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Short live Q_CONSTINIT!Marc Mutz2022-03-261-1/+1
| | | | | | | | | | | | | | | | | | It expands to the first available of - constinit (C++20) - [[clang::require_constant_initialization]] (Clang) - __constinit (GCC >= 10) Use it around the code (on and near static QBasicAtomic; this patch makes no attempt to find all statics in qtbase). [ChangeLog][QtCore][QtGlobal] Added macro Q_CONSTINIT. Fixes: QTBUG-100484 Change-Id: I11e0363a7acb3464476859d12ec7f94319d82be7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QImageReader: Check for existing handler in initHandlerRobert Löhning2022-02-021-3/+6
| | | | | | | | | Some calling code did this beforehand, other didn't. Now, the function itself checks for an existing handler before doing anything else. Change-Id: I8fc43fb8788c9dfe825b15ffa2fa69ee43915cd6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QImageReader: check allocation limit for minimum 32 bppEirik Aavitsland2021-11-221-1/+12
| | | | | | | | | | | | | | | | | Also, as a driveby, add an environment variable so the limit can be changed at runtime. [ChangeLog][QtGui][QImageReader] When checking allocation limit during image reading, the memory requirements are now calculated for a minimum of 32 bits per pixel, since Qt will typically convert an image to that depth when it is used in GUI. This means that the effective allocation limit is significantly smaller when reading 1 bpp and 8 bpp images. Pick-to: 6.2 6.2.2 Change-Id: If1b204d413973b0975eea531e29c260fdcec931d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove Qt6 switches from QtGuiAllan Sandfeld Jensen2021-05-051-4/+0
| | | | | | | Removing now dead code Change-Id: I021539da6517fdb8443f8ae9431fc172b7910cfc Reviewed-by: Friedemann Kleint <Friedemann.Kleint@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>
* Deprecate and remove all uses of AA_UseHighDpiPixmapsTor Arne Vestbø2020-08-311-1/+1
| | | | | | | High-DPI pixmaps are always enabled, and cannot be disabled. Change-Id: I01a006b404e5431582b64ef812974c1c022b39ae Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Another round of 0->nullptr cleanupAllan Sandfeld Jensen2020-07-311-1/+1
| | | | | Change-Id: Ic8db7dc252f8fea46eb5a4f334726d6c7f4645a6 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
* Introduce a settable allocation limit on image loadingEirik Aavitsland2020-06-261-0/+34
| | | | | | | | | | [ChangeLog][QtGui][QImageReader] Introduced a settable allocation limit on image loading to limit resource usage from corrupt image files. Change-Id: Ibed7b0cac32798125a060e6db80b17ebc5e70759 Task-number: QTBUG-85037 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Remove deprecated members from QtGui/image classesVolker Hilsheimer2020-04-291-37/+0
| | | | | | | | Cleaning up those that are trivial to remove because they have direct replacements. Change-Id: I4f5c25884a01474fa2db8b369f0d883bd21edd5b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Doc: Mark gamma-related functions deprecated in QImageReader/WriterTopi Reinio2020-03-261-1/+3
| | | | | | Change-Id: I0a9fbcca7a10a6555f5879cc4955f046eaa56602 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Deprecate QImageIOHandler gamma correctionAllan Sandfeld Jensen2020-01-301-0/+2
| | | | | | | | | Don't do gamma correction at image decoding time, it can be a whole lot more than just a simple gamma function, so it is better to use QColorSpace and QColorTransform. Change-Id: Iebc960bad6ecdd878240be965699d2df869572ad Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Replace usages of QVariant::value by qvariant_castOlivier Goffart2019-12-151-1/+1
| | | | | | | This is done automatically with a clazy check Change-Id: I3b59511d3d36d416c8eda74858ead611d327b116 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Tidy nullptr usageAllan Sandfeld Jensen2019-12-061-6/+6
| | | | | | | | | | | Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QtGui: replace some QMutexLockers with (new) qt_{scoped,unique}_lock()Marc Mutz2019-09-121-3/+3
| | | | | | | | In QImageReader, also replace a QMutex with a QBasicMutex, making the code similar to the corresponding code in QPicture. Change-Id: Ia1cd546eccd3662837762e506235e350b7a08647 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix loading of image files with wrong, but known, file name extensionEirik Aavitsland2019-07-181-2/+25
| | | | | | | | | | | | | | | | | | | | | If QImageReader recognized the suffix of a file, it would by default not check if the file contents matched the claimed format. Hence, a valid but misnamed image file would fail to load. Fix by adding contents check for suffix-recognized files. [ChangeLog][QtGui][Image] Loading of image files having a file name suffix for a different image file type has been fixed. QImageReader will now ask the suffix format handler to confirm the file contents (canRead()), and fall back to normal file content recognition on failure. This implies a slight behavior change in QImageReader::loopCount(), ::imageCount() and ::nextImageDelay(): For an unreadable file with a recognized suffix, they would earlier return 0, while they now will return -1, i.e. error as per the documentation. Fixes: QTBUG-42540 Fixes: QTBUG-68787 Change-Id: I205e83f29ed7190cbcae95dab960232544d012f6 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-07-171-1/+1
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/global/qlogging.cpp src/gui/painting/qtextureglyphcache_p.h src/gui/text/qfontengine.cpp src/widgets/widgets/qlineedit.cpp Change-Id: Ic8798538df466b7141caa8bbf1fb7605eb56be37
| * Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-07-121-1/+1
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: configure.pri Also required s/solid\.color/solidColor/ in a couple of places in: src/gui/painting/qpaintengine_raster.cpp Change-Id: I29937f63e9779deb6dac7ae77e2948d06ebc0319
| | * Doc: Fix incorrect enum value referenced in QImageReader::transformation()Topi Reinio2019-07-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | And remove the \c command to enable auto-linking. Fixes: QTBUG-76878 Change-Id: Ia2352942c7e7040088347becbda07062a9544c98 Reviewed-by: Nico Vertriest <nico.vertriest@qt.io>
| * | Merge remote-tracking branch 'origin/5.12' into 5.13Liang Qi2019-06-201-4/+6
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/gui/painting/qdrawhelper.cpp src/network/ssl/qsslsocket_openssl.cpp src/widgets/styles/qstylesheetstyle.cpp Change-Id: Ibe1cd40f46a823c9e5edbe0a3cd16be1e1686b17
* | | Merge remote-tracking branch 'origin/5.12' into devLiang Qi2019-06-251-4/+6
|\ \ \ | | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf src/gui/painting/qdrawhelper.cpp src/gui/text/qdistancefield.cpp src/gui/text/qdistancefield_p.h src/network/ssl/qsslsocket_openssl.cpp src/plugins/platforms/android/qandroidinputcontext.cpp src/widgets/styles/qstylesheetstyle.cpp Done-With: Timur Pocheptsov <timur.pocheptsov@qt.io> Change-Id: Ia7daad21f077ea889898f17734ec46303e71fe6b
| * | Generalize image file name @2x suffix handling to higher scale factorsEirik Aavitsland2019-06-141-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | @3x is in use on iOS already, so extend the handling in QImageReader to all single-digit factors, like QIcon does. Fixes: QTBUG-76273 Change-Id: Ic9442731c0549dbe8f797e1ddb1a09d8447e8441 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* | | Compile with Qt 6Lars Knoll2019-05-021-0/+2
| |/ |/| | | | | | | Change-Id: Ie45f4dc6d44723c8992872e6c4c2e30d7257ca0c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | QtGui: replace 0 with \nullptr in documentationChristian Ehrlicher2019-02-021-3/+3
| | | | | | | | | | | | | | | | | | Replace 0 with \nullptr in the documentation. As a drive-by also replace some 0 with nullptr in the corresponding code. Change-Id: Ieffbfffa76e3018257b667a3e8ad6e3b88486cde Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | Rename QList<T>::swap(int, int) to swapItemsAt()Lars Knoll2018-12-031-1/+1
|/ | | | | | | | | | | The old name was confusing as it conflicted with QList<T>::swap(QList &other), that was doing something completely different. Rename the method to swapItemsAt() which is a lot clearer. Change-Id: Iac77a1e790a7256766f83a24d2a243c880d875f4 Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
* QImageReader: add tracepoints for image loadingGiuseppe D'Angelo2018-10-141-1/+13
| | | | | Change-Id: I5fe25793eeda01a4fa1658091890af23f66b7089 Reviewed-by: Rafael Roquetto <rafael@roquetto.com>
* Fix documentation of QImage{Reader,Writer}::imageFormatsForMimeType()Friedemann Kleint2018-04-031-1/+1
| | | | | | | | | | | Fix a qdoc warning about unknown command \mimeType. Amends 37217c57fa5595e7cdfd7e19f34de22848dfc370. Task-number: QTBUG-49714 Change-Id: I48b38864e502164d9ccf5e2ba75bfd4084344ce0 Reviewed-by: Alexander Volkov <a.volkov@rusbitech.ru> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Introduce QImage{Reader,Writer}::imageFormatsForMimeType()Alexander Volkov2018-02-271-0/+17
| | | | | | | | | | It can be used if, for example, you get an image MIME type from the user, and you want to find the appropriate format for loading or saving this image. Task-number: QTBUG-49714 Change-Id: Iae5a7e9d658d6c3d1cd750a8bbc279f1812f99df Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Avoid code duplication in QImage{Reader,Writer}Alexander Volkov2018-02-111-98/+6
| | | | | | | | | Extract code related to supportedImageFormats() and supportedMimeTypes() into QImageReaderWriterHelpers namespace. Change-Id: If0f56682072859be1b6f07afd7737431325827fc Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-10-301-1/+9
|\ | | | | | | | | | | | | | | Conflicts: src/plugins/platforms/windows/qwindowswindow.cpp tests/auto/widgets/kernel/qaction/tst_qaction.cpp Change-Id: Ia017a825ed2ca2d53ac586f4ae48df6f65818d40
| * Doc: QImageReader assumes exclusive control over its deviceEirik Aavitsland2017-10-251-0/+5
| | | | | | | | | | | | | | | | | | Make an explicit mention of the fact that modifying a device while it is being held by a QImageReader is undefined. Task-number: QTBUG-61121 Change-Id: Ie0a016255c2614c5b8b415c8cd9602169153c8f8 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
| * Doc: add hint about QMimeDatabase to QImageReader::canRead()Eirik Aavitsland2017-10-241-1/+4
| | | | | | | | | | | | Task-number: QTBUG-63568 Change-Id: I5b700138487dbebfc8cbe70eb3a076efceafb361 Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-191-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qprocess_unix.cpp src/corelib/io/qprocess_win.cpp src/plugins/platforms/android/qandroidplatformintegration.h src/plugins/platforms/windows/qwindowscontext.cpp src/plugins/platforms/windows/windows.pri src/tools/uic/cpp/cppwriteinitialization.cpp src/widgets/doc/src/widgets-and-layouts/gallery.qdoc Change-Id: I8d0834c77f350ea7540140c2c7f372814afc2d0f
| * Fix QImageReader::supportedSubTypes()Eirik Aavitsland2017-06-071-1/+1
| | | | | | | | | | | | | | | | | | Because of inverted test logic, this function would always return an empty list. Task-number: QTBUG-61048 Change-Id: If1529f2c567069ab4b672f309268b4edaf84c42f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-04-071-1/+2
|\| | | | | | | | | | | | | | | | | | | Conflicts: mkspecs/linux-icc/qmake.conf mkspecs/macx-icc/qmake.conf mkspecs/win32-icc/qmake.conf src/gui/painting/qgrayraster.c Change-Id: Ib08c45ea3215be05f986ecb3e1f4b37d209aa775
| * No divide by zero if all imageformat features are disabledStephan Binner2017-04-041-1/+2
| | | | | | | | | | | | Change-Id: Ib3e8a4b62ae627bc3dc8541767dafff4e493d2f8 Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | QImageReader: Pass up information about resource errors on openRobin Burchell2017-03-221-1/+10
|/ | | | | | | | | | If a system runs out of FDs, there is no sense in trying to autodetect the format - as the real problem is the lack of FDs, not the non-existent file. Change-Id: I3302340859c3cc62995ac1b7b3c7b6e6326cb43e Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>