pixmap.loadfromdata fails using QT6.6.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
-
@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. -
@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. -
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.
-
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=0This image link loads successfully:
https://www.dropbox.com/scl/fi/lokdl52uhgzzz2asrvvob/file_loads_succesfully.png?rlkey=5tbz2jw83rpg0rs6k5wfo7d97&dl=0This image link fails to load:
https://www.dropbox.com/scl/fi/nf4m764boohn3at538u2t/file2_fails_to_load.png?rlkey=hdpnz0nu5jap0alqfix4alr6o&dl=0 -
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-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. -
@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.
-
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.
-
@rschnic
? The void QImageReader::setAllocationLimit(int mbLimit) is astatic
, 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 variableQT_IMAGEIO_MAXALLOC
instead. -