Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error when Loading QImage

Error when Loading QImage

Scheduled Pinned Locked Moved Solved General and Desktop
c++qt creatorqt 6.7.1qimageload image
13 Posts 3 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bapcruz
    wrote on 28 Apr 2024, 20:21 last edited by
    #1

    My program crashes when I try to load an image from my computer into a QImage. I made sure that the path to the file is correct and tried to make a QImage pointer, but it still results in an error. This was originally part of a larger program, but even in this simple recreation, it doesn't work.

    Here is my code in main.cpp:

    #include "mainwindow.h"
    
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        QImage test;
        test.load("C:/IMAGES/IMAGE.png"); // crashes program
        w.show();
        return a.exec();
    }
    

    Here is the error received when I used the debugger:

    qt.gui.imageio: libpng warning: iCCP: known incorrect sRGB profile
    HEAP[sdf.exe]:
    Invalid address specified to RtlFreeHeap( 00000000000D0000, 0000000000DF7240 )

    There are also no changes in mainwindow.cpp and the header file, but I added "CONFIG += console" to the .pro file.

    C 1 Reply Last reply 28 Apr 2024, 20:24
    0
    • H Offline
      H Offline
      hskoglund
      wrote on 28 Apr 2024, 23:17 last edited by
      #12

      When you mentioned you're using LLVM MinGW 64, is that the MinGW 11.2.0 64-bit compiler that can be installed via Qt's Maintenance app?

      B 1 Reply Last reply 28 Apr 2024, 23:31
      0
      • B bapcruz
        28 Apr 2024, 20:21

        My program crashes when I try to load an image from my computer into a QImage. I made sure that the path to the file is correct and tried to make a QImage pointer, but it still results in an error. This was originally part of a larger program, but even in this simple recreation, it doesn't work.

        Here is my code in main.cpp:

        #include "mainwindow.h"
        
        #include <QApplication>
        
        int main(int argc, char *argv[])
        {
            QApplication a(argc, argv);
            MainWindow w;
            QImage test;
            test.load("C:/IMAGES/IMAGE.png"); // crashes program
            w.show();
            return a.exec();
        }
        

        Here is the error received when I used the debugger:

        qt.gui.imageio: libpng warning: iCCP: known incorrect sRGB profile
        HEAP[sdf.exe]:
        Invalid address specified to RtlFreeHeap( 00000000000D0000, 0000000000DF7240 )

        There are also no changes in mainwindow.cpp and the header file, but I added "CONFIG += console" to the .pro file.

        C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 28 Apr 2024, 20:24 last edited by
        #2

        Can you load the png with a normal image viewer? Do other images work correct?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        0
        • B Offline
          B Offline
          bapcruz
          wrote on 28 Apr 2024, 20:31 last edited by
          #3

          @Christian-Ehrlicher I can open the image with windows photo viewer, photoshop, MS paint, etc. Also I've gotten no other images to load and I've had the same error for all of them. I've tried making the image a jpg and gif as well, but they seem to have the same error. It's also only about 5-6KB so I don't see it taking up too much memory. Here's the image for reference:

          Standing.png

          C 1 Reply Last reply 28 Apr 2024, 20:39
          0
          • B bapcruz
            28 Apr 2024, 20:31

            @Christian-Ehrlicher I can open the image with windows photo viewer, photoshop, MS paint, etc. Also I've gotten no other images to load and I've had the same error for all of them. I've tried making the image a jpg and gif as well, but they seem to have the same error. It's also only about 5-6KB so I don't see it taking up too much memory. Here's the image for reference:

            Standing.png

            C Offline
            C Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 28 Apr 2024, 20:39 last edited by
            #4

            What compiler do you use? How did you install Qt and please show your CMakeLists.txt.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            B 1 Reply Last reply 28 Apr 2024, 20:50
            0
            • C Christian Ehrlicher
              28 Apr 2024, 20:39

              What compiler do you use? How did you install Qt and please show your CMakeLists.txt.

              B Offline
              B Offline
              bapcruz
              wrote on 28 Apr 2024, 20:50 last edited by
              #5

              @Christian-Ehrlicher I'm using LLVM MinGW 64 with Qt 6.7.1 in my Qt Creator kit. I installed Qt through the open source installer on the website (https://www.qt.io/download-qt-installer-oss?hsCtaTracking=99d9dd4f-5681-48d2-b096-470725510d34|074ddad0-fdef-4e53-8aa8-5e8a876d6ab4). I installed Qt 6.7.1 through the Qt Creator maintenance tool. I also made the project using QMake, so I don't think I have a CMakeLists.txt file. Here's the .pro file though:

              QT       += core gui
              
              greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
              
              CONFIG += c++17
              CONFIG += console
              
              # You can make your code fail to compile if it uses deprecated APIs.
              # In order to do so, uncomment the following line.
              #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
              
              SOURCES += \
                  main.cpp \
                  mainwindow.cpp
              
              HEADERS += \
                  mainwindow.h
              
              FORMS += \
                  mainwindow.ui
              
              # Default rules for deployment.
              qnx: target.path = /tmp/$${TARGET}/bin
              else: unix:!android: target.path = /opt/$${TARGET}/bin
              !isEmpty(target.path): INSTALLS += target
              
              1 Reply Last reply
              0
              • H Offline
                H Offline
                hskoglund
                wrote on 28 Apr 2024, 21:39 last edited by
                #6

                If you try ,jpg or .gif files, do you still get the same warning, i.e " iCCP: known incorrect sRGB profile"?

                B 1 Reply Last reply 28 Apr 2024, 21:42
                0
                • H hskoglund
                  28 Apr 2024, 21:39

                  If you try ,jpg or .gif files, do you still get the same warning, i.e " iCCP: known incorrect sRGB profile"?

                  B Offline
                  B Offline
                  bapcruz
                  wrote on 28 Apr 2024, 21:42 last edited by
                  #7

                  @hskoglund I only get that part of the error for pngs.

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    hskoglund
                    wrote on 28 Apr 2024, 21:56 last edited by
                    #8

                    Just guessing, but if you disable your antivirus app, do you still get the same crash?

                    B 1 Reply Last reply 28 Apr 2024, 22:52
                    0
                    • H hskoglund
                      28 Apr 2024, 21:56

                      Just guessing, but if you disable your antivirus app, do you still get the same crash?

                      B Offline
                      B Offline
                      bapcruz
                      wrote on 28 Apr 2024, 22:52 last edited by
                      #9

                      @hskoglund I turned off Windows real time virus protection and disabled all UAC. I also ran QT Creator as admin, but the error is still occuring.

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        hskoglund
                        wrote on 28 Apr 2024, 23:02 last edited by
                        #10

                        Just to be sure it crashes in the test.load() statement, if you add a qDebug() directly after, you don't see any output from it in Qt Creator, like ...*QImage( ..." etc.? Say like this:

                        #include "mainwindow.h"
                        
                        #include <QApplication>
                        #include "qdebug.h"
                        
                        int main(int argc, char *argv[])
                        {
                            QApplication a(argc, argv);
                            MainWindow w;
                            QImage test;
                            test.load("C:/IMAGES/IMAGE.png"); // crashes program
                            qDebug() << test;
                            w.show();
                            return a.exec();
                        }
                        
                        B 1 Reply Last reply 28 Apr 2024, 23:07
                        0
                        • H hskoglund
                          28 Apr 2024, 23:02

                          Just to be sure it crashes in the test.load() statement, if you add a qDebug() directly after, you don't see any output from it in Qt Creator, like ...*QImage( ..." etc.? Say like this:

                          #include "mainwindow.h"
                          
                          #include <QApplication>
                          #include "qdebug.h"
                          
                          int main(int argc, char *argv[])
                          {
                              QApplication a(argc, argv);
                              MainWindow w;
                              QImage test;
                              test.load("C:/IMAGES/IMAGE.png"); // crashes program
                              qDebug() << test;
                              w.show();
                              return a.exec();
                          }
                          
                          B Offline
                          B Offline
                          bapcruz
                          wrote on 28 Apr 2024, 23:07 last edited by
                          #11

                          @hskoglund I tried that and the program seems to just stop and crash when I load (without displaying anything in the console with the qDebug). I also tried to qDebug a basic message after the load, but it doesn't seem to print that either.

                          1 Reply Last reply
                          0
                          • H Offline
                            H Offline
                            hskoglund
                            wrote on 28 Apr 2024, 23:17 last edited by
                            #12

                            When you mentioned you're using LLVM MinGW 64, is that the MinGW 11.2.0 64-bit compiler that can be installed via Qt's Maintenance app?

                            B 1 Reply Last reply 28 Apr 2024, 23:31
                            0
                            • H hskoglund
                              28 Apr 2024, 23:17

                              When you mentioned you're using LLVM MinGW 64, is that the MinGW 11.2.0 64-bit compiler that can be installed via Qt's Maintenance app?

                              B Offline
                              B Offline
                              bapcruz
                              wrote on 28 Apr 2024, 23:31 last edited by bapcruz
                              #13

                              @hskoglund Yes. I also have MinGW installed separately on my computer so I could try quickly making another kit with those and see if it works.

                              Edit: Changing the version of MinGW in the kit worked! I tried using regular MinGW 64-bit and that made it work perfectly. Thanks so much

                              1 Reply Last reply
                              0
                              • B bapcruz has marked this topic as solved on 28 Apr 2024, 23:43
                              • B bapcruz has marked this topic as solved on 28 Apr 2024, 23:43

                              2/13

                              28 Apr 2024, 20:24

                              topic:navigator.unread, 11
                              • Login

                              • Login or register to search.
                              2 out of 13
                              • First post
                                2/13
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved