Bug Summary

File:/home/gilles/Devel/8.x/core/libs/qtopencvimg/qtopencvimg.cpp
Warning:line 233, column 35
The left operand of '==' is a garbage value

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple aarch64-unknown-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name qtopencvimg.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=non-leaf -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -target-abi aapcs -debugger-tuning=gdb -fdebug-compilation-dir=/home/gilles/Devel/8.x/build.scan/core/libs/qtopencvimg -fcoverage-compilation-dir=/home/gilles/Devel/8.x/build.scan/core/libs/qtopencvimg -resource-dir /usr/lib/llvm-18/lib/clang/18 -D BUILDING_XMPCOMPAREANDMERGE_AS_STATIC=1 -D BUILDING_XMPCOMPAREANDMERGE_LIB=1 -D BanAllEntityUsage=1 -D CMS_NO_REGISTER_KEYWORD=1 -D EnablePluginManager=0 -D HAVE_FFMPEG_VERSION5 -D LIBPGF_DISABLE_OPENMP -D LINKING_XMPCORE_LIB=1 -D MAGICKCORE_HDRI_ENABLE=0 -D MAGICKCORE_QUANTUM_DEPTH=16 -D QT_DEPRECATED_WARNINGS -D QT_DEPRECATED_WARNINGS_SINCE=0x060000 -D QT_DISABLE_DEPRECATED_BEFORE=0x050E00 -D QT_NO_CAST_FROM_ASCII -D QT_NO_CAST_FROM_BYTEARRAY -D QT_NO_CAST_TO_ASCII -D QT_NO_FOREACH -D QT_NO_KEYWORDS -D QT_NO_NARROWING_CONVERSIONS_IN_CONNECT -D QT_NO_URL_CAST_FROM_STRING -D QT_STRICT_ITERATORS -D QT_USE_QSTRINGBUILDER -D TRANSLATION_DOMAIN="digikam" -D UNIX_ENV=1 -D USE_JASPER -D USE_JPEG -D USE_JPEG8 -D XMP_COMPONENT_INT_NAMESPACE=AdobeXMPCompareAndMerge_Int -D XMP_StaticBuild=1 -D _GNU_SOURCE -D _LARGEFILE64_SOURCE -D digikamcore_EXPORTS -D qDNGDebug=0 -D qDNGLittleEndian=1 -D qDNGThreadSafe=1 -D qDNGUseLibJPEG=1 -D qDNGUseStdInt=1 -D qDNGUseXMP=1 -D qDNGValidateTarget=1 -D qDNGXMPDocOps=0 -D qDNGXMPFiles=0 -D qLinux=1 -D qMacOS=0 -D qWinOS=0 -I /home/gilles/Devel/8.x/build.scan/core/libs/qtopencvimg -I /home/gilles/Devel/8.x/core/libs/qtopencvimg -I /home/gilles/Devel/8.x/build.scan/core/libs/qtopencvimg/core_qtopencvimg_obj_autogen/include -I /home/gilles/Devel/8.x/core/libs/video/player/qtmm -I /home/gilles/Devel/8.x/core/libs/album/engine -I /home/gilles/Devel/8.x/core/libs/album/manager -I /home/gilles/Devel/8.x/core/libs/album/treeview -I /home/gilles/Devel/8.x/core/libs/album/widgets -I /home/gilles/Devel/8.x/core/libs/database/collection -I /home/gilles/Devel/8.x/core/libs/database/coredb -I /home/gilles/Devel/8.x/core/libs/database/dbjobs -I /home/gilles/Devel/8.x/core/libs/database/engine -I /home/gilles/Devel/8.x/core/libs/database/haar -I /home/gilles/Devel/8.x/core/libs/database/history -I /home/gilles/Devel/8.x/core/libs/database/item/containers -I /home/gilles/Devel/8.x/core/libs/database/item/lister -I /home/gilles/Devel/8.x/core/libs/database/item/query -I /home/gilles/Devel/8.x/core/libs/database/item/scanner -I /home/gilles/Devel/8.x/core/libs/database/models -I /home/gilles/Devel/8.x/core/libs/database/server -I /home/gilles/Devel/8.x/core/libs/database/similaritydb -I /home/gilles/Devel/8.x/core/libs/database/tags -I /home/gilles/Devel/8.x/core/libs/database/thumbsdb -I /home/gilles/Devel/8.x/core/libs/database/utils/ifaces -I /home/gilles/Devel/8.x/core/libs/database/utils/scan -I /home/gilles/Devel/8.x/core/libs/database/utils/widgets -I /home/gilles/Devel/8.x/core/libs/dialogs -I /home/gilles/Devel/8.x/core/libs/dimg/color -I /home/gilles/Devel/8.x/core/libs/dimg -I /home/gilles/Devel/8.x/core/libs/dimg/filters/auto -I /home/gilles/Devel/8.x/core/libs/dimg/filters/bcg -I /home/gilles/Devel/8.x/core/libs/dimg/filters/bw -I /home/gilles/Devel/8.x/core/libs/dimg/filters/cb -I /home/gilles/Devel/8.x/core/libs/dimg/filters/curves -I /home/gilles/Devel/8.x/core/libs/dimg/filters/decorate -I /home/gilles/Devel/8.x/core/libs/dimg/filters -I /home/gilles/Devel/8.x/core/libs/dimg/filters/film -I /home/gilles/Devel/8.x/core/libs/dimg/filters/fx -I /home/gilles/Devel/8.x/core/libs/dimg/filters/greycstoration/cimg -I /home/gilles/Devel/8.x/core/libs/dimg/filters/greycstoration -I /home/gilles/Devel/8.x/core/libs/dimg/filters/hotpixels -I /home/gilles/Devel/8.x/core/libs/dimg/filters/hsl -I /home/gilles/Devel/8.x/core/libs/dimg/filters/icc -I /home/gilles/Devel/8.x/core/libs/dimg/filters/lc -I /home/gilles/Devel/8.x/core/libs/dimg/filters/lens -I /home/gilles/Devel/8.x/core/libs/dimg/filters/levels -I /home/gilles/Devel/8.x/core/libs/dimg/filters/nr -I /home/gilles/Devel/8.x/core/libs/dimg/filters/raw -I /home/gilles/Devel/8.x/core/libs/dimg/filters/redeye -I /home/gilles/Devel/8.x/core/libs/dimg/filters/sharp -I /home/gilles/Devel/8.x/core/libs/dimg/filters/transform -I /home/gilles/Devel/8.x/core/libs/dimg/filters/wb -I /home/gilles/Devel/8.x/core/libs/dimg/history -I /home/gilles/Devel/8.x/core/libs/dimg/loaders -I /home/gilles/Devel/8.x/core/libs/dngwriter -I /home/gilles/Devel/8.x/core/libs/dnnmodelmanager -I /home/gilles/Devel/8.x/core/libs/dplugins/core -I /home/gilles/Devel/8.x/core/libs/dplugins/iface -I /home/gilles/Devel/8.x/core/libs/dplugins/setup -I /home/gilles/Devel/8.x/core/libs/dplugins/webservices -I /home/gilles/Devel/8.x/core/libs/dplugins/widgets -I /home/gilles/Devel/8.x/core/libs/dragdrop -I /home/gilles/Devel/8.x/core/libs/dtrash -I /home/gilles/Devel/8.x/core/libs/facesengine/common -I /home/gilles/Devel/8.x/core/libs/facesengine/detection -I /home/gilles/Devel/8.x/core/libs/facesengine/detection/opencv-dnn -I /home/gilles/Devel/8.x/core/libs/facesengine/facedb -I /home/gilles/Devel/8.x/core/libs/facesengine/preprocessing -I /home/gilles/Devel/8.x/core/libs/facesengine/preprocessing/recognition -I /home/gilles/Devel/8.x/core/libs/facesengine/preprocessing/shape-predictor -I /home/gilles/Devel/8.x/core/libs/facesengine/recognition -I /home/gilles/Devel/8.x/core/libs/facesengine/recognition/opencv-dnn -I /home/gilles/Devel/8.x/core/libs/fileactionmanager -I /home/gilles/Devel/8.x/core/libs/filters -I /home/gilles/Devel/8.x/core/libs/imgqsort/detectors -I /home/gilles/Devel/8.x/core/libs/imgqsort -I /home/gilles/Devel/8.x/core/libs/iojobs -I /home/gilles/Devel/8.x/core/libs/jpegutils -I /home/gilles/Devel/8.x/core/libs/metadataengine/containers -I /home/gilles/Devel/8.x/core/libs/metadataengine/dmetadata -I /home/gilles/Devel/8.x/core/libs/metadataengine/engine -I /home/gilles/Devel/8.x/core/libs/metadataengine/exiftool -I /home/gilles/Devel/8.x/core/libs/metadataengine/focuspoint -I /home/gilles/Devel/8.x/core/libs/mlfoundation -I /home/gilles/Devel/8.x/core/libs/models -I /home/gilles/Devel/8.x/core/libs/networkmanager -I /home/gilles/Devel/8.x/core/libs/notificationmanager -I /home/gilles/Devel/8.x/core/libs/onlineversion -I /home/gilles/Devel/8.x/core/libs/pgfutils -I /home/gilles/Devel/8.x/core/libs/progressmanager -I /home/gilles/Devel/8.x/core/libs/properties/captions -I /home/gilles/Devel/8.x/core/libs/properties/geolocation -I /home/gilles/Devel/8.x/core/libs/properties/history -I /home/gilles/Devel/8.x/core/libs/properties/import -I /home/gilles/Devel/8.x/core/libs/properties -I /home/gilles/Devel/8.x/core/libs/rawengine -I /home/gilles/Devel/8.x/core/libs/settings -I /home/gilles/Devel/8.x/core/libs/tags/autoassignment -I /home/gilles/Devel/8.x/core/libs/tags/autoassignment/model -I /home/gilles/Devel/8.x/core/libs/tags/engine -I /home/gilles/Devel/8.x/core/libs/tags/manager/models -I /home/gilles/Devel/8.x/core/libs/tags/manager -I /home/gilles/Devel/8.x/core/libs/tags/widgets -I /home/gilles/Devel/8.x/core/libs/template -I /home/gilles/Devel/8.x/core/libs/threadimageio/engine -I /home/gilles/Devel/8.x/core/libs/threadimageio/fileio -I /home/gilles/Devel/8.x/core/libs/threadimageio/preview -I /home/gilles/Devel/8.x/core/libs/threadimageio/thumb -I /home/gilles/Devel/8.x/core/libs/threadimageio/video -I /home/gilles/Devel/8.x/core/libs/threads -I /home/gilles/Devel/8.x/core/libs/timeadjust -I /home/gilles/Devel/8.x/core/libs/transitionmngr -I /home/gilles/Devel/8.x/core/libs/versionmanager -I /home/gilles/Devel/8.x/core/libs/video -I /home/gilles/Devel/8.x/core/libs/video/manager -I /home/gilles/Devel/8.x/core/libs/video/osd -I /home/gilles/Devel/8.x/core/libs/video/player -I /home/gilles/Devel/8.x/core/libs/widgets/colors -I /home/gilles/Devel/8.x/core/libs/widgets/combo -I /home/gilles/Devel/8.x/core/libs/widgets/files -I /home/gilles/Devel/8.x/core/libs/widgets/fonts -I /home/gilles/Devel/8.x/core/libs/widgets/graphicsview -I /home/gilles/Devel/8.x/core/libs/widgets/history -I /home/gilles/Devel/8.x/core/libs/widgets/iccprofiles -I /home/gilles/Devel/8.x/core/libs/widgets/itemview -I /home/gilles/Devel/8.x/core/libs/widgets/layout -I /home/gilles/Devel/8.x/core/libs/widgets/mainview -I /home/gilles/Devel/8.x/core/libs/widgets/metadata/config -I /home/gilles/Devel/8.x/core/libs/widgets/metadata/exiftool -I /home/gilles/Devel/8.x/core/libs/widgets/metadata/exiv2 -I /home/gilles/Devel/8.x/core/libs/widgets/metadata/labels -I /home/gilles/Devel/8.x/core/libs/widgets/metadata/utils -I /home/gilles/Devel/8.x/core/libs/widgets/range -I /home/gilles/Devel/8.x/core/libs/widgets/text -I /home/gilles/Devel/8.x/core/libs/jpegutils/libjpeg/84 -I /home/gilles/Devel/8.x/core/app/utils -I /home/gilles/Devel/8.x/build.scan/core/app/utils -I /home/gilles/Devel/8.x/core/utilities/advancedrename -I /home/gilles/Devel/8.x/core/utilities/advancedrename/common -I /home/gilles/Devel/8.x/core/utilities/advancedrename/parser -I /home/gilles/Devel/8.x/core/utilities/advancedrename/parser/modifiers -I /home/gilles/Devel/8.x/core/utilities/advancedrename/parser/options -I /home/gilles/Devel/8.x/core/utilities/advancedrename/parser/options/database -I /home/gilles/Devel/8.x/core/utilities/advancedrename/parser/options/database/keys -I /home/gilles/Devel/8.x/core/utilities/extrasupport/addressbook -I /home/gilles/Devel/8.x/core/utilities/extrasupport/filesindexer -I /home/gilles/Devel/8.x/core/utilities/facemanagement/bench -I /home/gilles/Devel/8.x/core/utilities/facemanagement/database -I /home/gilles/Devel/8.x/core/utilities/facemanagement/dialogs -I /home/gilles/Devel/8.x/core/utilities/facemanagement/items -I /home/gilles/Devel/8.x/core/utilities/facemanagement/pipelines/detect -I /home/gilles/Devel/8.x/core/utilities/facemanagement/pipelines/detectrecognize -I /home/gilles/Devel/8.x/core/utilities/facemanagement/pipelines/edit -I /home/gilles/Devel/8.x/core/utilities/facemanagement/pipelines -I /home/gilles/Devel/8.x/core/utilities/facemanagement/pipelines/recognize -I /home/gilles/Devel/8.x/core/utilities/facemanagement/pipelines/reset -I /home/gilles/Devel/8.x/core/utilities/facemanagement/pipelines/retrain -I /home/gilles/Devel/8.x/core/utilities/facemanagement/threads -I /home/gilles/Devel/8.x/core/utilities/facemanagement/widgets -I /home/gilles/Devel/8.x/core/utilities/facemanagement/workers -I /home/gilles/Devel/8.x/core/utilities/firstrun -I /home/gilles/Devel/8.x/core/utilities/focuspointmanagement -I /home/gilles/Devel/8.x/core/utilities/fuzzysearch -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/astro -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/blendings -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/core -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/data -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/graphicsitem -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/handlers/dgml -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/handlers/kml -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/parser -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/scene -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/writer -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/writers/dgml -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/geodata/writers/kml -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/graphicsview -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/layers -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/models -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/osm -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/atmosphere -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/compass -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/crosshairs -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/graticule -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/mapscale -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/measure -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/navigation -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/overviewmap -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/render/progress -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/cache -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/gpsbabel -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/gpx -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/gpx/handlers -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/json -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/kml -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/nominatim-reversegeocoding -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/osm -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/osm/o5mreader -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/osm/translators -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/osm/writers -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/pn2 -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/plugins/runner/pnt -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/projections -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/runners -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/settings -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/storage -I /home/gilles/Devel/8.x/core/utilities/geolocation/engine/tile -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/backends -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/bookmark -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/core -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/correlator -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/dragdrop -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/items -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/lookup -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/reversegeocoding -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/tiles -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/tracks -I /home/gilles/Devel/8.x/core/utilities/geolocation/geoiface/widgets -I /home/gilles/Devel/8.x/core/utilities/geolocation/geomapwrapper -I /home/gilles/Devel/8.x/core/utilities/geolocation/mapsearches -I /home/gilles/Devel/8.x/core/utilities/imageeditor/core -I /home/gilles/Devel/8.x/core/utilities/imageeditor/dialogs -I /home/gilles/Devel/8.x/core/utilities/imageeditor/editor -I /home/gilles/Devel/8.x/core/utilities/imageeditor/main -I /home/gilles/Devel/8.x/core/utilities/imageeditor/widgets -I /home/gilles/Devel/8.x/core/utilities/import/backend -I /home/gilles/Devel/8.x/core/utilities/import/dialogs -I /home/gilles/Devel/8.x/core/utilities/import/items -I /home/gilles/Devel/8.x/core/utilities/import/main -I /home/gilles/Devel/8.x/core/utilities/import/models -I /home/gilles/Devel/8.x/core/utilities/import/views -I /home/gilles/Devel/8.x/core/utilities/import/widgets -I /home/gilles/Devel/8.x/core/utilities/lighttable -I /home/gilles/Devel/8.x/core/utilities/maintenance/main -I /home/gilles/Devel/8.x/core/utilities/maintenance/manager -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/autotags -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/dbcleaner -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/dbscan -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/duplicates -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/facesmanagement -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/fingerprints -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/imgqsort -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/metaremover -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/metasync -I /home/gilles/Devel/8.x/core/utilities/maintenance/tools/thumbs -I /home/gilles/Devel/8.x/core/utilities/maintenance/utils -I /home/gilles/Devel/8.x/core/utilities/queuemanager/dplugins -I /home/gilles/Devel/8.x/core/utilities/queuemanager/main -I /home/gilles/Devel/8.x/core/utilities/queuemanager/manager -I /home/gilles/Devel/8.x/core/utilities/queuemanager/views -I /home/gilles/Devel/8.x/core/utilities/searchwindow -I /home/gilles/Devel/8.x/core/utilities/setup/album -I /home/gilles/Devel/8.x/core/utilities/setup/camera -I /home/gilles/Devel/8.x/core/utilities/setup/collections -I /home/gilles/Devel/8.x/core/utilities/setup/downloader -I /home/gilles/Devel/8.x/core/utilities/setup/editor -I /home/gilles/Devel/8.x/core/utilities/setup/metadata -I /home/gilles/Devel/8.x/core/utilities/setup/misc -I /home/gilles/Devel/8.x/core/utilities/setup -I /home/gilles/Devel/8.x/core/app/main -I /home/gilles/Devel/8.x/core/app/date -I /home/gilles/Devel/8.x/core/app/dragdrop -I /home/gilles/Devel/8.x/core/app/views/stack -I /home/gilles/Devel/8.x/core/app/views/utils -I /home/gilles/Devel/8.x/core/app/items/utils -I /home/gilles/Devel/8.x/core/app/items/delegate -I /home/gilles/Devel/8.x/core/app/views/sidebar -I /usr/include/opencv4 -I /usr/include/ImageMagick-6 -I /usr/include/aarch64-linux-gnu/ImageMagick-6 -I /opt/qt6/include/QtMultimedia -I /opt/qt6/include -I /opt/qt6/include/QtCore -I /opt/qt6/mkspecs/linux-g++ -I /opt/qt6/include/QtGui -I /opt/qt6/include/QtNetwork -I /opt/qt6/include/QtMultimediaWidgets -I /opt/qt6/include/QtWidgets -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/13/../../../../include/c++/13 -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/13/../../../../include/aarch64-linux-gnu/c++/13 -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/13/../../../../include/c++/13/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/aarch64-linux-gnu/13/../../../../aarch64-linux-gnu/include -internal-externc-isystem /usr/include/aarch64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-long-long -Wno-deprecated-copy -std=c++20 -fdeprecated-macro -ferror-limit 19 -fvisibility=hidden -fvisibility-inlines-hidden -fno-operator-names -fopenmp -fno-signed-char -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -analyzer-output=html -target-feature +outline-atomics -target-feature -fmv -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /mnt/data/Devel/8.x/project/reports/report.scan/2024-12-26-143353-2621840-1 -x c++ /home/gilles/Devel/8.x/core/libs/qtopencvimg/qtopencvimg.cpp
1/* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2024-12-23
7 * Description : Helper methods to convert OpenCV image to Qt containers and vis-versa.
8 *
9 * SPDX-FileCopyrightText: 2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
10 * SPDX-FileCopyrightText: 2024 by Michael Miller <michael underscore miller at msn dot com>
11 * SPDX-FileCopyrightText: 2012-2015 by Debao Zhang <hello at debao dot me>
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 *
15 * ============================================================ */
16
17#include "qtopencvimg.h"
18
19// Qt includes
20
21#include <QSysInfo>
22#include <QDebug>
23
24namespace Digikam
25{
26
27namespace
28{
29
30/**
31 * Convert ARGB to BGRA
32 */
33cv::Mat argb2bgra(const cv::Mat& mat)
34{
35 Q_ASSERT(mat.channels() == 4)((mat.channels() == 4) ? static_cast<void>(0) : qt_assert
("mat.channels() == 4", "/home/gilles/Devel/8.x/core/libs/qtopencvimg/qtopencvimg.cpp"
, 35))
;
36
37 cv::Mat newMat(mat.rows, mat.cols, mat.type());
38 int from_to[] = { 0, 3, 1, 2, 2, 1, 3, 0 };
39 cv::mixChannels(&mat, 1, &newMat, 1, from_to, 4);
40
41 return newMat;
42}
43
44cv::Mat adjustChannelsOrder(const cv::Mat& srcMat, MatColorOrder srcOrder, MatColorOrder targetOrder)
45{
46 Q_ASSERT(srcMat.channels() == 4)((srcMat.channels() == 4) ? static_cast<void>(0) : qt_assert
("srcMat.channels() == 4", "/home/gilles/Devel/8.x/core/libs/qtopencvimg/qtopencvimg.cpp"
, 46))
;
47
48 if (srcOrder == targetOrder)
49 {
50 return srcMat.clone();
51 }
52
53 cv::Mat desMat;
54
55 if (
56 ((srcOrder == MCO_ARGB) && (targetOrder == MCO_BGRA)) ||
57 ((srcOrder == MCO_BGRA) && (targetOrder == MCO_ARGB))
58 )
59 {
60 // ARGB <==> BGRA
61
62 desMat = argb2bgra(srcMat);
63 }
64 else if (srcOrder == MCO_ARGB && targetOrder == MCO_RGBA)
65 {
66 // ARGB ==> RGBA
67
68 desMat = cv::Mat(srcMat.rows, srcMat.cols, srcMat.type());
69 int from_to[] = { 0, 3, 1, 0, 2, 1, 3, 2 };
70 cv::mixChannels(&srcMat, 1, &desMat, 1, from_to, 4);
71 }
72 else if (srcOrder == MCO_RGBA && targetOrder == MCO_ARGB)
73 {
74 // RGBA ==> ARGB
75
76 desMat = cv::Mat(srcMat.rows, srcMat.cols, srcMat.type());
77 int from_to[] = { 0, 1, 1, 2, 2, 3, 3, 0 };
78 cv::mixChannels(&srcMat, 1, &desMat, 1, from_to, 4);
79 }
80
81 else
82 {
83 // BGRA <==> RBGA
84
85 cv::cvtColor(srcMat, desMat, CV_BGRA2RGBA);
86 }
87
88 return desMat;
89}
90
91QImage::Format findClosestFormat(QImage::Format formatHint)
92{
93 QImage::Format format = QImage::Format_Invalid;
94
95 switch (formatHint)
96 {
97 case QImage::Format_Indexed8:
98 case QImage::Format_RGB32:
99 case QImage::Format_ARGB32:
100 case QImage::Format_ARGB32_Premultiplied:
101
102#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x040400
103
104 case QImage::Format_RGB888:
105
106#endif
107
108#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x050200
109
110 case QImage::Format_RGBX8888:
111 case QImage::Format_RGBA8888:
112 case QImage::Format_RGBA8888_Premultiplied:
113
114#endif
115
116#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x050500
117
118 case QImage::Format_Alpha8:
119 case QImage::Format_Grayscale8:
120
121#endif
122
123 format = formatHint;
124
125 break;
126
127 case QImage::Format_Mono:
128 case QImage::Format_MonoLSB:
129
130 format = QImage::Format_Indexed8;
131
132 break;
133
134 case QImage::Format_RGB16:
135
136 format = QImage::Format_RGB32;
137
138 break;
139
140#if QT_VERSION((6<<16)|(8<<8)|(0)) > 0x040400
141
142 case QImage::Format_RGB444:
143 case QImage::Format_RGB555:
144 case QImage::Format_RGB666:
145
146 format = QImage::Format_RGB888;
147 break;
148
149 case QImage::Format_ARGB4444_Premultiplied:
150 case QImage::Format_ARGB6666_Premultiplied:
151 case QImage::Format_ARGB8555_Premultiplied:
152 case QImage::Format_ARGB8565_Premultiplied:
153
154 format = QImage::Format_ARGB32_Premultiplied;
155
156 break;
157
158#endif
159
160 default:
161
162 format = QImage::Format_ARGB32;
163
164 break;
165 }
166
167 return format;
168}
169
170MatColorOrder getColorOrderOfRGB32Format()
171{
172
173#if Q_BYTE_ORDER1234 == Q_LITTLE_ENDIAN1234
174
175 return MCO_BGRA;
176
177#else
178
179 return MCO_ARGB;
180
181#endif
182
183}
184
185} // namespace
186
187/**
188 * Convert QImage to cv::Mat
189 */
190cv::Mat image2Mat(const QImage& img, int requiredMatType, MatColorOrder requriedOrder)
191{
192 int targetDepth = CV_MAT_DEPTH(requiredMatType)((requiredMatType) & ((1 << 3) - 1));
193 int targetChannels = CV_MAT_CN(requiredMatType)((((requiredMatType) & ((512 - 1) << 3)) >> 3
) + 1)
;
194
195 Q_ASSERT((targetChannels == CV_CN_MAX) || (targetChannels == 1) || (targetChannels == 3) || (targetChannels == 4))(((targetChannels == 512) || (targetChannels == 1) || (targetChannels
== 3) || (targetChannels == 4)) ? static_cast<void>(0)
: qt_assert("(targetChannels == CV_CN_MAX) || (targetChannels == 1) || (targetChannels == 3) || (targetChannels == 4)"
, "/home/gilles/Devel/8.x/core/libs/qtopencvimg/qtopencvimg.cpp"
, 195))
;
1
Assuming 'targetChannels' is not equal to 512
2
Assuming 'targetChannels' is equal to 1
196 Q_ASSERT((targetDepth == CV_8U) || (targetDepth == CV_16U) || (targetDepth == CV_32F))(((targetDepth == 0) || (targetDepth == 2) || (targetDepth ==
5)) ? static_cast<void>(0) : qt_assert("(targetDepth == CV_8U) || (targetDepth == CV_16U) || (targetDepth == CV_32F)"
, "/home/gilles/Devel/8.x/core/libs/qtopencvimg/qtopencvimg.cpp"
, 196))
;
3
Assuming 'targetDepth' is equal to 0
197
198 if (img.isNull())
4
Assuming the condition is false
5
Taking false branch
199 {
200 return cv::Mat();
201 }
202
203 // Find the closest image format that can be used in image2Mat_shared()
204
205 QImage::Format format = findClosestFormat(img.format());
206 QImage image = (format == img.format()) ? img : img.convertToFormat(format);
6
Assuming the condition is true
7
'?' condition is true
207
208 MatColorOrder srcOrder;
8
'srcOrder' declared without an initial value
209 cv::Mat mat0 = image2Mat_shared(image, &srcOrder);
9
Calling 'image2Mat_shared'
13
Returning from 'image2Mat_shared'
210
211 // Adjust mat channels if needed.
212
213 cv::Mat mat_adjustCn;
214 const float maxAlpha = (targetDepth
13.1
'targetDepth' is equal to CV_8U
== CV_8U0) ? 255
14
'?' condition is true
215 : ((targetDepth == CV_16U2) ? 65535
216 : 1.0);
217
218 if (targetChannels
14.1
'targetChannels' is not equal to CV_CN_MAX
== CV_CN_MAX512)
15
Taking false branch
219 {
220 targetChannels = mat0.channels();
221 }
222
223 switch (targetChannels)
16
Control jumps to 'case 1:' at line 225
224 {
225 case 1:
226
227 if (mat0.channels() == 3)
17
Assuming the condition is false
18
Taking false branch
228 {
229 cv::cvtColor(mat0, mat_adjustCn, CV_RGB2GRAY);
230 }
231 else if (mat0.channels() == 4)
19
Assuming the condition is true
20
Taking true branch
232 {
233 if (srcOrder == MCO_BGRA)
21
The left operand of '==' is a garbage value
234 {
235 cv::cvtColor(mat0, mat_adjustCn, CV_BGRA2GRAY);
236 }
237 else if (srcOrder == MCO_RGBA)
238 {
239 cv::cvtColor(mat0, mat_adjustCn, CV_RGBA2GRAY);
240 }
241 else // MCO_ARGB
242 {
243 cv::cvtColor(argb2bgra(mat0), mat_adjustCn, CV_BGRA2GRAY);
244 }
245 }
246
247 break;
248
249 case 3:
250
251 if (mat0.channels() == 1)
252 {
253 cv::cvtColor(mat0, mat_adjustCn, (requriedOrder == MCO_BGR) ? CV_GRAY2BGR : CV_GRAY2RGB);
254 }
255 else if (mat0.channels() == 3)
256 {
257 if (requriedOrder != srcOrder)
258 {
259 cv::cvtColor(mat0, mat_adjustCn, CV_RGB2BGR);
260 }
261 }
262
263 else if (mat0.channels() == 4)
264 {
265 if (srcOrder == MCO_ARGB)
266 {
267 mat_adjustCn = cv::Mat(mat0.rows, mat0.cols, CV_MAKE_TYPE(mat0.type(), 3)(((mat0.type()) & ((1 << 3) - 1)) + (((3)-1) <<
3))
);
268 int ARGB2RGB[] = { 1, 0, 2, 1, 3, 2 };
269 int ARGB2BGR[] = { 1, 2, 2, 1, 3, 0 };
270 cv::mixChannels(&mat0, 1, &mat_adjustCn, 1, (requriedOrder == MCO_BGR) ? ARGB2BGR : ARGB2RGB, 3);
271 }
272 else if (srcOrder == MCO_BGRA)
273 {
274 cv::cvtColor(mat0, mat_adjustCn, (requriedOrder == MCO_BGR) ? CV_BGRA2BGR : CV_BGRA2RGB);
275 }
276 else // RGBA
277 {
278 cv::cvtColor(mat0, mat_adjustCn, (requriedOrder == MCO_BGR) ? CV_RGBA2BGR : CV_RGBA2RGB);
279 }
280 }
281
282 break;
283
284 case 4:
285
286 if (mat0.channels() == 1)
287 {
288 if (requriedOrder == MCO_ARGB)
289 {
290 cv::Mat alphaMat(mat0.rows, mat0.cols, CV_MAKE_TYPE(mat0.type(), 1)(((mat0.type()) & ((1 << 3) - 1)) + (((1)-1) <<
3))
, cv::Scalar(maxAlpha));
291 mat_adjustCn = cv::Mat(mat0.rows, mat0.cols, CV_MAKE_TYPE(mat0.type(), 4)(((mat0.type()) & ((1 << 3) - 1)) + (((4)-1) <<
3))
);
292 cv::Mat in[] = {alphaMat, mat0};
293 int from_to[] = {0, 0, 1, 1, 1, 2, 1, 3};
294 cv::mixChannels(in, 2, &mat_adjustCn, 1, from_to, 4);
295 }
296 else if (requriedOrder == MCO_RGBA)
297 {
298 cv::cvtColor(mat0, mat_adjustCn, CV_GRAY2RGBA);
299 }
300 else // MCO_BGRA
301 {
302 cv::cvtColor(mat0, mat_adjustCn, CV_GRAY2BGRA);
303 }
304 }
305 else if (mat0.channels() == 3)
306 {
307 if (requriedOrder == MCO_ARGB)
308 {
309 cv::Mat alphaMat(mat0.rows, mat0.cols, CV_MAKE_TYPE(mat0.type(), 1)(((mat0.type()) & ((1 << 3) - 1)) + (((1)-1) <<
3))
, cv::Scalar(maxAlpha));
310 mat_adjustCn = cv::Mat(mat0.rows, mat0.cols, CV_MAKE_TYPE(mat0.type(), 4)(((mat0.type()) & ((1 << 3) - 1)) + (((4)-1) <<
3))
);
311 cv::Mat in[] = { alphaMat, mat0 };
312 int from_to[] = { 0, 0, 1, 1, 2, 2, 3, 3 };
313 cv::mixChannels(in, 2, &mat_adjustCn, 1, from_to, 4);
314 }
315 else if (requriedOrder == MCO_RGBA)
316 {
317 cv::cvtColor(mat0, mat_adjustCn, CV_RGB2RGBA);
318 }
319 else // MCO_BGRA
320 {
321 cv::cvtColor(mat0, mat_adjustCn, CV_RGB2BGRA);
322 }
323 }
324 else if (mat0.channels() == 4)
325 {
326 if (srcOrder != requriedOrder)
327 {
328 mat_adjustCn = adjustChannelsOrder(mat0, srcOrder, requriedOrder);
329 }
330 }
331
332 break;
333
334 default:
335
336 break;
337 }
338
339 // Adjust depth if needed.
340
341 if (targetDepth == CV_8U0)
342 {
343 return (mat_adjustCn.empty() ? mat0.clone() : mat_adjustCn);
344 }
345
346 if (mat_adjustCn.empty())
347 {
348 mat_adjustCn = mat0;
349 }
350
351 cv::Mat mat_adjustDepth;
352 mat_adjustCn.convertTo(mat_adjustDepth,
353 CV_MAKE_TYPE(targetDepth, mat_adjustCn.channels())(((targetDepth) & ((1 << 3) - 1)) + (((mat_adjustCn
.channels())-1) << 3))
,
354 (targetDepth == CV_16U2) ? 255.0 : 1 / 255.0);
355
356 return mat_adjustDepth;
357}
358
359/**
360 * Convert cv::Mat to QImage
361 */
362QImage mat2Image(const cv::Mat& mat, MatColorOrder order, QImage::Format formatHint)
363{
364 Q_ASSERT((mat.channels() == 1) || (mat.channels() == 3) || (mat.channels() == 4))(((mat.channels() == 1) || (mat.channels() == 3) || (mat.channels
() == 4)) ? static_cast<void>(0) : qt_assert("(mat.channels() == 1) || (mat.channels() == 3) || (mat.channels() == 4)"
, "/home/gilles/Devel/8.x/core/libs/qtopencvimg/qtopencvimg.cpp"
, 364))
;
365 Q_ASSERT((mat.depth() == CV_8U) || (mat.depth() == CV_16U) || (mat.depth() == CV_32F))(((mat.depth() == 0) || (mat.depth() == 2) || (mat.depth() ==
5)) ? static_cast<void>(0) : qt_assert("(mat.depth() == CV_8U) || (mat.depth() == CV_16U) || (mat.depth() == CV_32F)"
, "/home/gilles/Devel/8.x/core/libs/qtopencvimg/qtopencvimg.cpp"
, 365))
;
366
367 if (mat.empty())
368 {
369 return QImage();
370 }
371
372 // Adjust mat channels if needed, and find proper QImage format.
373
374 QImage::Format format = QImage::Format_Invalid;
375 cv::Mat mat_adjustCn;
376
377 if (mat.channels() == 1)
378 {
379 format = formatHint;
380
381 if ( (formatHint != QImage::Format_Indexed8)
382
383#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x050500
384
385 && (formatHint != QImage::Format_Alpha8)
386 && (formatHint != QImage::Format_Grayscale8)
387
388#endif
389
390 )
391 {
392 format = QImage::Format_Indexed8;
393 }
394 }
395
396 else if (mat.channels() == 3)
397 {
398
399#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x040400
400
401 format = QImage::Format_RGB888;
402
403 if (order == MCO_BGR)
404 {
405 cv::cvtColor(mat, mat_adjustCn, CV_BGR2RGB);
406 }
407
408#else
409
410 format = QImage::Format_RGB32;
411 cv::Mat mat_tmp;
412 cv::cvtColor(mat, mat_tmp, (order == MCO_BGR) ? CV_BGR2BGRA : CV_RGB2BGRA);
413
414# if Q_BYTE_ORDER1234 == Q_LITTLE_ENDIAN1234
415
416 mat_adjustCn = mat_tmp;
417
418# else
419
420 mat_adjustCn = argb2bgra(mat_tmp);
421
422# endif
423
424#endif
425
426 }
427
428 else if (mat.channels() == 4)
429 {
430 // Find best format if the formatHint can not be applied.
431
432 format = findClosestFormat(formatHint);
433
434 if ( (format != QImage::Format_RGB32)
435 && (format != QImage::Format_ARGB32)
436 && (format != QImage::Format_ARGB32_Premultiplied)
437
438#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x050200
439
440 && (format != QImage::Format_RGBX8888)
441 && (format != QImage::Format_RGBA8888)
442 && (format != QImage::Format_RGBA8888_Premultiplied)
443
444#endif
445
446 )
447 {
448
449#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x050200
450
451 format = order == MCO_RGBA ? QImage::Format_RGBA8888 : QImage::Format_ARGB32;
452
453#else
454
455 format = QImage::Format_ARGB32;
456
457#endif
458
459 }
460
461 // Channel order requried by the target QImage
462
463 MatColorOrder requiredOrder = getColorOrderOfRGB32Format();
464
465#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x050200
466
467 if ( (formatHint == QImage::Format_RGBX8888)
468 || (formatHint == QImage::Format_RGBA8888)
469 || (formatHint == QImage::Format_RGBA8888_Premultiplied))
470 {
471 requiredOrder = MCO_RGBA;
472 }
473
474#endif
475
476 if (order != requiredOrder)
477 {
478 mat_adjustCn = adjustChannelsOrder(mat, order, requiredOrder);
479 }
480 }
481
482 if (mat_adjustCn.empty())
483 {
484 mat_adjustCn = mat;
485 }
486
487 // Adjust mat depth if needed.
488
489 cv::Mat mat_adjustDepth = mat_adjustCn;
490
491 if (mat.depth() != CV_8U0)
492 {
493 mat_adjustCn.convertTo(mat_adjustDepth, CV_8UC(mat_adjustCn.channels())(((0) & ((1 << 3) - 1)) + ((((mat_adjustCn.channels
()))-1) << 3))
, (mat.depth() == CV_16U2) ? 1 / 255.0 : 255.0);
494 }
495
496 // Should we convert the image to the format specified by formatHint?
497
498 QImage image = mat2Image_shared(mat_adjustDepth, format);
499
500 if ((format == formatHint) || (formatHint == QImage::Format_Invalid))
501 {
502 return image.copy();
503 }
504 else
505 {
506 return image.convertToFormat(formatHint);
507 }
508}
509
510/**
511 * Convert QImage to cv::Mat without data copy
512 */
513cv::Mat image2Mat_shared(const QImage& img, MatColorOrder* order)
514{
515 if (img.isNull())
10
Assuming the condition is true
11
Taking true branch
516 {
517 return cv::Mat();
12
Returning without writing to '*order'
518 }
519
520 switch (img.format())
521 {
522 case QImage::Format_Indexed8:
523
524 break;
525
526#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x040400
527
528 case QImage::Format_RGB888:
529
530 if (order)
531 {
532 *order = MCO_RGB;
533 }
534
535 break;
536
537#endif
538
539 case QImage::Format_RGB32:
540 case QImage::Format_ARGB32:
541 case QImage::Format_ARGB32_Premultiplied:
542
543 if (order)
544 {
545 *order = getColorOrderOfRGB32Format();
546 }
547
548 break;
549
550#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x050200
551
552 case QImage::Format_RGBX8888:
553 case QImage::Format_RGBA8888:
554 case QImage::Format_RGBA8888_Premultiplied:
555
556 if (order)
557 {
558 *order = MCO_RGBA;
559 }
560
561 break;
562
563#endif
564
565#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x050500
566
567 case QImage::Format_Alpha8:
568 case QImage::Format_Grayscale8:
569
570 break;
571
572#endif
573
574 default:
575
576 return cv::Mat();
577 }
578
579 return cv::Mat(img.height(), img.width(), CV_8UC(img.depth() / 8)(((0) & ((1 << 3) - 1)) + ((((img.depth() / 8))-1) <<
3))
, (uchar*)img.bits(), img.bytesPerLine());
580}
581
582/**
583 * Convert cv::Mat to QImage without data copy
584 */
585QImage mat2Image_shared(const cv::Mat& mat, QImage::Format formatHint)
586{
587 Q_ASSERT((mat.type() == CV_8UC1) || (mat.type() == CV_8UC3) || (mat.type() == CV_8UC4))(((mat.type() == (((0) & ((1 << 3) - 1)) + (((1)-1)
<< 3))) || (mat.type() == (((0) & ((1 << 3) -
1)) + (((3)-1) << 3))) || (mat.type() == (((0) & (
(1 << 3) - 1)) + (((4)-1) << 3)))) ? static_cast<
void>(0) : qt_assert("(mat.type() == CV_8UC1) || (mat.type() == CV_8UC3) || (mat.type() == CV_8UC4)"
, "/home/gilles/Devel/8.x/core/libs/qtopencvimg/qtopencvimg.cpp"
, 587))
;
588
589 if (mat.empty())
590 {
591 return QImage();
592 }
593
594 // Adjust formatHint if needed.
595
596 if (mat.type() == CV_8UC1(((0) & ((1 << 3) - 1)) + (((1)-1) << 3)))
597 {
598 // cppcheck-suppress duplicateConditionalAssign
599 if ( (formatHint != QImage::Format_Indexed8)
600
601#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x050500
602
603 && (formatHint != QImage::Format_Alpha8)
604 && (formatHint != QImage::Format_Grayscale8)
605
606#endif
607
608 )
609 {
610 // cppcheck-suppress duplicateConditionalAssign
611 formatHint = QImage::Format_Indexed8;
612 }
613
614#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x040400
615
616 }
617
618 else if (mat.type() == CV_8UC3(((0) & ((1 << 3) - 1)) + (((3)-1) << 3)))
619 {
620 formatHint = QImage::Format_RGB888;
621
622#endif
623
624 }
625
626 else if (mat.type() == CV_8UC4(((0) & ((1 << 3) - 1)) + (((4)-1) << 3)))
627 {
628 if ( (formatHint != QImage::Format_RGB32)
629 && (formatHint != QImage::Format_ARGB32)
630 && (formatHint != QImage::Format_ARGB32_Premultiplied)
631
632#if QT_VERSION((6<<16)|(8<<8)|(0)) >= 0x050200
633
634 && (formatHint != QImage::Format_RGBX8888)
635 && (formatHint != QImage::Format_RGBA8888)
636 && (formatHint != QImage::Format_RGBA8888_Premultiplied)
637
638#endif
639
640 )
641 {
642 formatHint = QImage::Format_ARGB32;
643 }
644 }
645
646 QImage img(mat.data, mat.cols, mat.rows, mat.step, formatHint);
647
648 // Should we add directly support for user-customed-colorTable?
649
650 if (formatHint == QImage::Format_Indexed8)
651 {
652 QVector<QRgb> colorTable;
653
654 for (int i = 0 ; i < 256 ; ++i)
655 {
656 colorTable.append(qRgb(i, i, i));
657 }
658
659 img.setColorTable(colorTable);
660 }
661
662 return img;
663}
664
665} // namespace Digikam