[SOLVED] Images not loading with QImage.load
-
Hi,
I'm trying to load an image file into a QImage using the function:
@
backgroundImage.load(myImageFileName)
@I've tried PNG, JPG and BMP files but none of them work (the function returns 'false').
I tried to debug this by using the QImageReader:
@
QImageReader myImage(imageFileName.c_str());
myImage.read(&backgroundImage);
qDebug() << myImage.error();
qDebug() << myImage.errorString();
@This returns:
"0"
"Unknown error"I've tried listing the supported image formats
@qDebug() << QImageReader::supportedImageFormats();@and this gives:
("BW", "EPS", "EPSF", "EPSI", "EXR", "PCX", "PSD", "RAS", "RGB", "RGBA", "SGI", "TGA", "XCF", "bmp", "bw", "dds", "eps", "epsf", "epsi", "exr", "gif", "ico", "jp2", "jpeg", "jpg", "mng", "pbm", "pcx", "pgm", "pic", "png", "ppm", "psd", "ras", "rgb", "rgba", "sgi", "svg", "svgz", "tga", "xbm", "xcf", "xpm", "xv")
Does anyone have any ideas please? I've copied the image plugins into a directory named 'plugins' in the same directory as the executable.
Thanks in advance.
-
Which platform?
-
OpenSUSE Linux 11.4 - I've tried using the full path and relative addressing (i.e. Just the filename)
-
If that list of supported formats comes from the deployed system (not your dev system) then there's no reason for the image load to fail unless the image files are corrupt or missing.
-
Thanks - I have versions of this on the dev and deployed system and both give the same error.
Extra things I've tried (to no avail) are:
- different pictures and filetypes (JPG & PNG)
- selecting the file using QFileDialog::getOpenFileName() to ensure file path correct
- Trying backgroundImage=myImage.read() instead of myImage.read(&backgroundImage);
One new message I've seen is:
@kfilemodule(27138)/kio (KDirModel) KDirModelPrivate::_k_slotDeleteItems: No node found for item that was just removed: KUrl("file:///home/yalnte/testpic1.png")@
Is this related?
The problem must be due to something silly - I might have to leave this and then come back to it another time with fresh eyes.
-
I Rewrote this bit of code from scratch and it now works. Not sure what problem was exactly, but believe there was some kind of garbled conversion between std::string, QString and a c_str version of Filename. Thanks for your help.