Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. pixmap.loadfromdata fails using QT6.6.1

pixmap.loadfromdata fails using QT6.6.1

Scheduled Pinned Locked Moved Solved Qt 6
13 Posts 4 Posters 1.3k 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.
  • R Offline
    R Offline
    rschnic
    wrote on last edited by
    #1

    I have just updated an app from QT5.1.2 to QT6.6.1 and the qpixmap.loadfromdata() function now refuses to load some larger images with either PNG or JPG format. One additional detail is that Gwenview on my 64 bit Ubuntu station will not load these files either but Gimp will. It appears to be QT6 related. Here is my code:

    QPixmap VisualScene::loadBackground(const QString type)
    {
        QPixmap pix;
        QString buffer="";
        QString bg="";
    
        buffer = QString("SELECT file FROM job_files WHERE job_id = %1 AND int_rev = %2 AND subject = '%3'").arg(mainWin->job_id).arg( mainWin->int_rev).arg(bg);
            QSqlQuery query(buffer, mainWin->db);
        while (query.next())
        {
            bool ret = pix.loadFromData(query.record().field("file").value().toByteArray());
            if (!ret) fprintf(stderr, "Invalid pixmap.\n");
            }
        query.clear();
        if (pix.isNull()) qDebug("No gerber or image pixmap found.");
        return pix;
    } /** end loadBackground **/
    
    

    The images are in a MySQL database as a BLOB. I have verified the images downloaded from the database open in Gimp but not Gwenview. Also, this same app complied for Windows 10, QT6.6.1 has the same problem.

    I am baffeled.

    Rick

    Christian EhrlicherC 1 Reply Last reply
    0
    • R rschnic

      I have just updated an app from QT5.1.2 to QT6.6.1 and the qpixmap.loadfromdata() function now refuses to load some larger images with either PNG or JPG format. One additional detail is that Gwenview on my 64 bit Ubuntu station will not load these files either but Gimp will. It appears to be QT6 related. Here is my code:

      QPixmap VisualScene::loadBackground(const QString type)
      {
          QPixmap pix;
          QString buffer="";
          QString bg="";
      
          buffer = QString("SELECT file FROM job_files WHERE job_id = %1 AND int_rev = %2 AND subject = '%3'").arg(mainWin->job_id).arg( mainWin->int_rev).arg(bg);
              QSqlQuery query(buffer, mainWin->db);
          while (query.next())
          {
              bool ret = pix.loadFromData(query.record().field("file").value().toByteArray());
              if (!ret) fprintf(stderr, "Invalid pixmap.\n");
              }
          query.clear();
          if (pix.isNull()) qDebug("No gerber or image pixmap found.");
          return pix;
      } /** end loadBackground **/
      
      

      The images are in a MySQL database as a BLOB. I have verified the images downloaded from the database open in Gimp but not Gwenview. Also, this same app complied for Windows 10, QT6.6.1 has the same problem.

      I am baffeled.

      Rick

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @rschnic said in pixmap.loadfromdata fails using QT6.6.1:

      database open in Gimp but not Gwenview

      Then maybe gimp ignores some problems with the file.
      Make sure the data you read from the db is exactly what you write into by e.g. comparing checksums. Also try to open the data you put into the db with Qt.

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

      R 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @rschnic said in pixmap.loadfromdata fails using QT6.6.1:

        database open in Gimp but not Gwenview

        Then maybe gimp ignores some problems with the file.
        Make sure the data you read from the db is exactly what you write into by e.g. comparing checksums. Also try to open the data you put into the db with Qt.

        R Offline
        R Offline
        rschnic
        wrote on last edited by
        #3

        @Christian-Ehrlicher
        I have done all that. This app as worked for years complied under Qt5.1.2. I also tried exporting the image from Gimp to another format and it still wouldn't load with either Gwenview or my app. The images will also load in several viewers on Windows. The only viewers having problems are those based on Qt6.

        Christian EhrlicherC SGaistS 2 Replies Last reply
        0
        • R rschnic

          @Christian-Ehrlicher
          I have done all that. This app as worked for years complied under Qt5.1.2. I also tried exporting the image from Gimp to another format and it still wouldn't load with either Gwenview or my app. The images will also load in several viewers on Windows. The only viewers having problems are those based on Qt6.

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I can load and save png and jpg files just fine. Please provide a minimal, compilable example of your problem (as you wrote the db is not needed) including the probelmatic picture.

          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
          • R rschnic

            @Christian-Ehrlicher
            I have done all that. This app as worked for years complied under Qt5.1.2. I also tried exporting the image from Gimp to another format and it still wouldn't load with either Gwenview or my app. The images will also load in several viewers on Windows. The only viewers having problems are those based on Qt6.

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @rschnic hi and welcome to devnet,

            Did you saw any error message on the command line with regard to these images ?

            Would it be possible for you to share an example of each image to test ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            R 1 Reply Last reply
            0
            • SGaistS SGaist

              @rschnic hi and welcome to devnet,

              Did you saw any error message on the command line with regard to these images ?

              Would it be possible for you to share an example of each image to test ?

              R Offline
              R Offline
              rschnic
              wrote on last edited by
              #6

              @SGaist

              There were no detailed errors thrown. Only fail to load error from "loadfromdata()".

              I did try using Qt6.7.0 but has same problem.

              The image files were to large to upload so providing links to share.

              This image link fails to load:
              https://www.dropbox.com/scl/fi/ufh0905yhpbzlwmh6hsgd/file_fails_to_load.png?rlkey=p6q6w1aeay6qe9toueg7nm6ux&dl=0

              This image link loads successfully:
              https://www.dropbox.com/scl/fi/lokdl52uhgzzz2asrvvob/file_loads_succesfully.png?rlkey=5tbz2jw83rpg0rs6k5wfo7d97&dl=0

              This image link fails to load:
              https://www.dropbox.com/scl/fi/nf4m764boohn3at538u2t/file2_fails_to_load.png?rlkey=hdpnz0nu5jap0alqfix4alr6o&dl=0

              R 1 Reply Last reply
              0
              • R rschnic

                @SGaist

                There were no detailed errors thrown. Only fail to load error from "loadfromdata()".

                I did try using Qt6.7.0 but has same problem.

                The image files were to large to upload so providing links to share.

                This image link fails to load:
                https://www.dropbox.com/scl/fi/ufh0905yhpbzlwmh6hsgd/file_fails_to_load.png?rlkey=p6q6w1aeay6qe9toueg7nm6ux&dl=0

                This image link loads successfully:
                https://www.dropbox.com/scl/fi/lokdl52uhgzzz2asrvvob/file_loads_succesfully.png?rlkey=5tbz2jw83rpg0rs6k5wfo7d97&dl=0

                This image link fails to load:
                https://www.dropbox.com/scl/fi/nf4m764boohn3at538u2t/file2_fails_to_load.png?rlkey=hdpnz0nu5jap0alqfix4alr6o&dl=0

                R Offline
                R Offline
                rschnic
                wrote on last edited by
                #7

                I did just notice when not using debug mode on QtCreator the error message appears after load attempt.

                qt.gui.imageio: QImageIOHandler: Rejecting image as it exceeds the current allocation limit of 256 megabytes

                Was there a change in Qt6 that might have caused this?

                Christian EhrlicherC 1 Reply Last reply
                0
                • R rschnic

                  I did just notice when not using debug mode on QtCreator the error message appears after load attempt.

                  qt.gui.imageio: QImageIOHandler: Rejecting image as it exceeds the current allocation limit of 256 megabytes

                  Was there a change in Qt6 that might have caused this?

                  Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @rschnic See https://doc.qt.io/qt-6/qimagereader.html#setAllocationLimit

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

                  R 1 Reply Last reply
                  2
                  • Christian EhrlicherC Christian Ehrlicher

                    @rschnic See https://doc.qt.io/qt-6/qimagereader.html#setAllocationLimit

                    R Offline
                    R Offline
                    rschnic
                    wrote on last edited by
                    #9

                    @Christian-Ehrlicher
                    This seems like it is only for QImageReader. Am I wrong on that. While I could use the this class I would have to figure out how to get bytes from the database read into it.

                    Christian EhrlicherC 1 Reply Last reply
                    0
                    • R rschnic

                      @Christian-Ehrlicher
                      This seems like it is only for QImageReader. Am I wrong on that. While I could use the this class I would have to figure out how to get bytes from the database read into it.

                      Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @rschnic said in pixmap.loadfromdata fails using QT6.6.1:

                      This seems like it is only for QImageReader

                      Every image in Qt is read with QImageReader.

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

                      R 1 Reply Last reply
                      1
                      • Christian EhrlicherC Christian Ehrlicher

                        @rschnic said in pixmap.loadfromdata fails using QT6.6.1:

                        This seems like it is only for QImageReader

                        Every image in Qt is read with QImageReader.

                        R Offline
                        R Offline
                        rschnic
                        wrote on last edited by
                        #11

                        @Christian-Ehrlicher

                        Not to sound like a complete moron but I have found nothing in the QPixMap or QImage classes that would let me adjust that setting.

                        JonBJ 1 Reply Last reply
                        0
                        • R rschnic

                          @Christian-Ehrlicher

                          Not to sound like a complete moron but I have found nothing in the QPixMap or QImage classes that would let me adjust that setting.

                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by JonB
                          #12

                          @rschnic
                          ? The void QImageReader::setAllocationLimit(int mbLimit) is a static, which @Christian-Ehrlicher says will affect all reads of image files, no matter where they emanate from. Did you try it for your case? Or it says you can just set environment variable QT_IMAGEIO_MAXALLOC instead.

                          R 1 Reply Last reply
                          2
                          • JonBJ JonB

                            @rschnic
                            ? The void QImageReader::setAllocationLimit(int mbLimit) is a static, which @Christian-Ehrlicher says will affect all reads of image files, no matter where they emanate from. Did you try it for your case? Or it says you can just set environment variable QT_IMAGEIO_MAXALLOC instead.

                            R Offline
                            R Offline
                            rschnic
                            wrote on last edited by
                            #13

                            @JonB

                            That fixed it! Thanks Christian and Jon for your help.

                            Sorry to be such a pain Christian.

                            Rick

                            1 Reply Last reply
                            0
                            • R rschnic has marked this topic as solved on

                            • Login

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