summaryrefslogtreecommitdiffstats
path: root/src/gui/image
Commit message (Collapse)AuthorAgeFilesLines
* QPixmapCache: guard against usage from non-main threadsEirik Aavitsland2019-07-101-0/+33
| | | | | | | | | | | | | | | | | | | Depending on the active QPA plugin, QPixmaps may now be created and used also in non-main threads. But QPixmapCache is not designed to be used from such threads, so add guards to ignore such access attempts, both from application code and from Qt library code. Such unsafe access would often cause a cryptical "~QObject: Timers cannot be stopped from another thread" warning; that also disappears with this fix. [ChangeLog][QtGui][QPixmapCache] Ignore unsafe access from non-main threads Task-number: QTBUG-76694 Task-number: QTBUG-72523 Change-Id: Ia2db37e528aec08bfb48808630bdf5e543689039 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* 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>
* Do not downscale png when the size is exactly rightAleix Pol2019-06-261-1/+1
| | | | | | | | | | | | | | Don't go through the doScaledRead path (i.e. calling read_image_scaled) when reading an image that the target size is the image of the file we are opening. This makes the loading of the file much faster while keeping the output correct. [ChangeLog][QtGui][QImage] Improve loading time when loading png files that have the same size as the target. Change-Id: I2a33c49fe1ce52ec296c2175ee542b5bcdec2c4b Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* 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>
* png handler: initialize all the variables passed to png_get_IHDRAlbert Astals Cid2019-04-051-4/+4
| | | | | | | | | | | | | oss-fuzz found at least width is sometimes not initialized, and we're initializing almost all of them in most cases so be complete. the oss-fuzz instance was ==1==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x667c43 in operator!= /src/qtbase/src/corelib/tools/qsize.h:173:25 #1 0x667c43 in setup_qt /src/qtbase/src/gui/image/qpnghandler.cpp:403 Change-Id: Idb9aaf5ab85509d9c893beaf8d9118339ba46be7 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Doc: Update QImage::depth to indicate we support 64 bpp nowAndy Shaw2019-04-041-1/+1
| | | | | Change-Id: Icbd4920ed03655cec483a402de9d0ae3378ff3ef Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Update scanline documentationAllan Sandfeld Jensen2019-04-041-1/+3
| | | | | Change-Id: I019b102e99f99377b528ad5c8a4ccb2a7929f14f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Forward physical parameters for derived QImagesAlexander Volkov2019-04-011-9/+27
| | | | | | | | | | More specifically, for masks and rotated images. Add tests for it, also add tests that image metadata is forwarded for converted and copied images. Fixes: QTBUG-49259 Change-Id: I05d4a468b17f53a2625500b871c01b2c53b981a1 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Forward devicePixelRatio in QPixmap::mask()Alexander Volkov2019-04-011-0/+1
| | | | | | | | Also add a test checking that devicePixelRatio is forwarded to derivatives of QPixmap. Change-Id: Idb2b3f033ccc0fd49bf54b11f5dffbce5a19b006 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Speculative fix for building on INTEGRITY with ARM NEONAllan Sandfeld Jensen2019-03-291-45/+21
| | | | | | | | Avoid using inline assembler Task-number: QTBUG-72716 Change-Id: I696efb5a787416eb4fc5ba3a250461aaa9a4afc2 Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
* QPixmap: More safe failing if qApp is not a QGuiApplicationAlbert Astals Cid2019-03-221-0/+15
| | | | | | | | | | | | | | | It can happen that QDataStream is fed a QVariant that contains a QPixmap representation, that will make the application crash when trying to restore it This is specially important for cases in which applications expose dbus interfaces with QVariantMaps Change-Id: Ife4feaef30f30e7e27d88464bd6b2a247f743123 Reported-by: Fabian Vogt <fabian@ritter-vogt.de> Reviewed-by: Fabian Vogt <fabian@ritter-vogt.de> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Handle device pixel ratio in QIconLoaderEngine::paint()Alexander Volkov2019-03-201-1/+4
| | | | | | | | | QIcon::paint() paints blurry icons on HighDPI screens. In particular, it is called by QCommonStyle to paint icons for CE_ItemViewItem's. Change-Id: Iffe6bd01a8756e617656195ef63fe13c968e0832 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Avoid creating wide images with negative bytesPerLineAllan Sandfeld Jensen2019-02-143-2/+19
| | | | | | | | | | The QImage API can not handle images with more bytes per line than what an integer can hold. Fixes: QTBUG-73731 Fixes: QTBUG-73732 Change-Id: Ieed6fec7645661fd58d8d25335f806faaa1bb3e9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix xbm image format handler: properly reject invalid filesEirik Aavitsland2019-02-051-0/+4
| | | | | | | | | The read_xbm_header() function is used to check for valid file header, containing valid width and height values. But in case of an invalid file, the check could depend on uninitialized variables. Change-Id: I9f933ed6e38d86109e5b5a8d55fe763ab928d749 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Initialize bit_depthAlbert Astals Cid2019-01-311-2/+2
| | | | | | | | ==12==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x6b90ea in setup_qt /src/qtbase/src/gui/image/qpnghandler.cpp:360:32 Change-Id: Idf04130e645dcf589dfb6260661be18a71b7bdc2 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* QPictureIO::read(): don't work on dangling pointerChristian Ehrlicher2019-01-301-2/+2
| | | | | | | | | | QPictureIO::read() is using pictureFormat() when the format has to be guessed. pictureFormat() returns a QByteArray which was implicit casted into a char* and then pointed to uninitialized memory. Fix it by using a QByteArray instead a plain char*. Change-Id: If9ae286ed68134af597f0b0c779789e40f9efaed Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* png: initialize color_type to 0Albert Astals Cid2019-01-301-2/+2
| | | | | | | | | | Fixes ==12==WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x6b8179 in setup_qt /src/qtbase/src/gui/image/qpnghandler.cpp:247:9 on fuzzed file Change-Id: I772d536a0db91665dc16e94751ef507de1064376 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Prevent QPixmap::load from touching QPixmapCache in non-gui threadsJoni Poikelin2019-01-281-4/+6
| | | | | | Change-Id: Ied0fec48c81298743f694f317dd60e58d356f69a Fixes: QTBUG-72523 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Merge remote-tracking branch 'origin/5.12.1' into 5.12Qt Forward Merge Bot2019-01-232-2/+2
|\ | | | | | | Change-Id: Icebd151eae0cf9d400319a42573290d1a911ce26
| * bmp image handler: Reject invalid 0-dimension files earlyEirik Aavitsland2019-01-081-1/+1
| | | | | | | | | | | | | | | | | | | | Avoid spending time on decoding attempt of invalid bmp files specifying height or width as 0. Change-Id: Ia6666088515eee54777f7154868fb7d07c6b4438 Done-with: Albert Astals Cid <albert.astals.cid@kdab.com> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
| * Merge remote-tracking branch 'origin/5.12' into 5.12.1Liang Qi2019-01-081-2/+5
| |\ | | | | | | | | | | | | | | | | | | Conflicts: src/widgets/kernel/qtooltip.cpp Change-Id: Ic2f9a425359050eb56b3a4e5162cf5e3447058c8
| * | Doc: Fix link in QImage::load() documentationTopi Reinio2019-01-041-1/+1
| | | | | | | | | | | | | | | Change-Id: I9a3a059a860f5b21253ab0e7cdc616cbfc9a3885 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | | Documentation: Add \nullptr macro and use where applicableFriedemann Kleint2019-01-101-1/+1
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Qt for Python users reading the documentation assume that int(0) can be passed for pointer parameters. Use the newly introduced \nullptr to disambiguate this. In a follow-up step, the \nullptr macro can be defined as None when generating the Qt for Python documentation. Task-number: PYSIDE-903 Change-Id: I3a45f87175a0668ab5f3f95f0aff409f7e3ef027 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* | qt_imageFromWinHBITMAP(): Fix memory corruption when converting from bitmaps ↵Friedemann Kleint2018-12-121-2/+5
|/ | | | | | | | | | | with low depths Insufficient memory was allocated when asking GetDIBits() to convert to 32bit. Fix allocation size and use a QScopedArrayPointer. Fixes: QTBUG-72343 Change-Id: I45f79c913a243316e01bc6efed08e50ccc7d25f4 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* Revert "Ensure alignment of image-data"Allan Sandfeld Jensen2018-12-081-11/+3
| | | | | | | | | | | This reverts commit ae8389e19c5804c867b2981311c623003a691474. The result of malloc should be aligned in any case, and this change conflicts with the use of realloc on the data elsewhere. Change-Id: I01773132b240614a2656dd3013490b0df9cd14a7 Reviewed-by: Kirill Burtsev <kirill.burtsev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add a note about virtual_hookThiago Macieira2018-12-071-0/+1
| | | | | Change-Id: I1ff3b344ec5a4499bb25fffd156b2bf6a7d88625 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* macOS: Share code for resolving CGImage bitmapInfor for a QImageTor Arne Vestbø2018-11-281-25/+4
| | | | | | | Removes assumptions about QImage format in a few places. Change-Id: I515701be53190429a48956c31986fa0804806406 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Ensure alignment of image-dataAllan Sandfeld Jensen2018-11-281-3/+11
| | | | | | | | Instead of relying on the return value of malloc having the correct alignment, use proper non-throwing new[] operators. Change-Id: I06c6c619e21c848f3d184bdb7cef8c5589c1c7ab Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.11' into 5.12Liang Qi2018-11-191-2/+4
|\ | | | | | | | | | | | | Conflicts: src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm Change-Id: I66a08c770767a93cd26535689e3e7806486aab06
| * Modernize the "settings" featureLiang Qi2018-11-151-2/+4
| | | | | | | | | | | | Change-Id: I9b8a61ecb1413b513ae5c9e77d3ee1b3e8b6562c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | QImageWriter: improve documentation regarding use of resourcesSamuel Gaist2018-11-121-0/+10
| | | | | | | | | | | | | | | | | | | | QImageWriter's plugin can open devices while operating and only free them on destruction which means that if one wants to act on the file written if must first destroy the writer's instance. This patch adds the suggestion to use a scope to avoid that problem. Change-Id: I239157ea86c4a93faab237fe1860312a3c7ac7a2 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into 5.12Liang Qi2018-11-091-1/+0
|\| | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf qmake/Makefile.unix src/gui/text/qtextdocument.cpp src/gui/text/qtextdocument.h Change-Id: Iba26da0ecbf2aa4ff4b956391cfb373f977f88c9
| * Modernize the "textcodec" featureLiang Qi2018-11-071-1/+0
| | | | | | | | | | | | | | | | | | Also clean up QTextCodec usage in qmake build and some includes of qtextcodec.h. Change-Id: I0475b82690024054add4e85a8724c8ea3adcf62a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | QImage: merge the size calculations with proper (non-UB) checksThiago Macieira2018-11-083-70/+93
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This check, which was only done once, was wrong: const int bytes_per_line = ((width * depth + 31) >> 5) << 2; // sanity check for potential overflows if (std::numeric_limits<int>::max()/depth < width If width*height overflows, then it's already UB and checking afterwards with a division is pointless and slow. The other instances weren't properly guarding against overflows. Change-Id: I343f2beed55440a7ac0bfffd1563350d4cfa639c Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | QMovie: use rvalue moreAnton Kudryavtsev2018-10-211-2/+2
| | | | | | | | | | | | Change-Id: Idf052436190bf225662ff6c1d4b7b8e3c0c84685 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into 5.12Qt Forward Merge Bot2018-10-211-11/+12
|\| | | | | | | Change-Id: Iaf28977e7ecf566b28b9406dcb005d48621169c2
| * QPicture: fix crash for malformed pictureEirik Aavitsland2018-10-181-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | A file with the correct QPicture magic bytes, but shorter than a full QPicture file header, could cause the header decoder to access memory out of bounds. Add a size check to avoid. As a driveby, generally harden the parsing against malformed files. [ChangeLog][QtGui][QPicture] Fix crash reading malformed picture file Task-number: QTBUG-71208 Change-Id: I86eb1f915ca9b3a4b91c7433036d76ed6061e2f0 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into 5.12Liang Qi2018-10-171-2/+4
|\| | | | | | | | | | | | | | | Conflicts: src/plugins/platformthemes/platformthemes.pro src/printsupport/kernel/qplatformprintdevice.cpp Change-Id: Iac01729ad954bb1c7af5867d982eb243b2139ee6
| * Modernize the "mimetype" featureLiang Qi2018-10-121-2/+4
| | | | | | | | | | | | Change-Id: I9b67c2cbc0891a38ece18d521c86fbc7344dce7a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | Improve support for QImages in QDataStream read transactionsEirik Aavitsland2018-10-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QImage's operator>>(QDataStream&) did not set an error mode on the stream on read failures. That would break QDataStream transactions. Since the current QImage serialization cannot differentiate between truncated and corrupted data, we set the ReadPastEnd error as expected by the transaction system. Also specify the expected file format on decoding QImage from stream, to avoid all the format handlers' canRead() being invoked. This is necessary since some of them may call ungetChar(), which fails when the stream is in a transaction. Also add testing of this feature to the QDataStram transaction autotest. That required a slight rewrite of the fake sequential QIODevice subclass. The previous implementation had incorrect behavior of peek(), which is required by QImage decoders. Task-number: QTBUG-70875 Change-Id: If3f1ca7186ad1e6ca0e6e8ea81d2b2fbece6ea01 Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | QImageReader: add tracepoints for image loadingGiuseppe D'Angelo2018-10-141-1/+13
| | | | | | | | | | Change-Id: I5fe25793eeda01a4fa1658091890af23f66b7089 Reviewed-by: Rafael Roquetto <rafael@roquetto.com>
* | QImageWriter/QPNGHandler: Quality option should be CompressionRatioAlexandra Cherdantseva2018-10-141-19/+31
| | | | | | | | | | | | | | | | | | | | | | Wrong option was used to set zlib compression level for png setCompression with negative value uses default compression setCompression with value between 0-100 converts to zlib compression level 0-9 setCompression with positive value overrides Quality option Change-Id: Ic4b048a1e30d6940019c2a00a6c24d0c11e3f821 Reviewed-by: Alexandra Cherdantseva <neluhus.vagus@gmail.com> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | QPixmap: use rvalue moreAnton Kudryavtsev2018-10-101-3/+2
| | | | | | | | | | Change-Id: Ifb8c014abf6e02dc782fab2d653e4edfc4972125 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | Add missing null checks after detachAllan Sandfeld Jensen2018-10-101-2/+14
| | | | | | | | | | | | | | | | | | A few places we didn't check if detach() succeeded including in reinterpretAsFormat(), where it can be undone. Task-number: QTBUG-70785 Change-Id: Ibcc8e26e2961f6288eb7a045ae1cb28e59213a49 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | Add NEON optimized ARGB32 unpremultiply routinesAllan Sandfeld Jensen2018-10-091-2/+15
| | | | | | | | | | | | | | | | Mirroring similar routines recently added for SSE4.1 Change-Id: Ibb9d10cc34655ce1dc0e97fdff4e4f6a81d47d05 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io> Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
* | QImageWriter: Fix default compressionratioEirik Aavitsland2018-09-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Before asking a image format handler to save an image, QImageWriter sets the value of all supported options. For options like quality and gamma, the default value is an illegal value (-1 and 0.0 resp.), effectively telling the handler that the application has not requested any particular value. But in the case of compressionratio, the default was 0, a legal value. Fix by changing it to -1. Change-Id: Iad6d4c2dbe269b25863e7d4967aa9ed2a7d1247f Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | Merge remote-tracking branch 'origin/5.11' into 5.12Qt Forward Merge Bot2018-09-141-0/+2
|\| | | | | | | Change-Id: Ic4c1a8041dcfd143861c39e0014fbdaaa3fb25c6
| * bmp image handler: check for out of range image sizeEirik Aavitsland2018-09-111-0/+2
| | | | | | | | | | | | | | | | Make the decoder fail early to avoid spending time and memory on attempting to decode a corrupt image file. Change-Id: I874e04f3b43122d73f8e58c7a5bcc4a741b68264 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | Fix spelling mistake in qimage.hTor Arne Vestbø2018-09-131-1/+1
| | | | | | | | | | | | Change-Id: I2138318894587cc0b5f03af14a57b2a39509f0da Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* | Fix reading 16bpc grayscale PNGsAllan Sandfeld Jensen2018-09-031-17/+20
| | | | | | | | | | | | | | | | | | They were incorrectly attempted to be read as Indexed8, instead use the RGBA64 formats to read them with full accuracy. Task-number: QTBUG-45858 Change-Id: I14fc3cb0d59fa2fc0e68fd870f3b32352c34161f Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>