Error when Loading QImage
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:
Code:
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
MainWindow w;
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.
Re: Error when Loading QImage
Hi, is the image a valid .png file? How large is it? Have you tried other .png files?
Ginsengelf
Re: Error when Loading QImage
The error you are getting may be due to the Qt platform lacking a plugin for the format you are trying to use, or the image path may be incorrect or the image may be corrupted. Check for file path errors.
Re: Error when Loading QImage
PNG format support is built in to Qt; it does not require a plugin. And since the OP's example provides an absolute path to the image file, a path error is probably not the cause. I would suspect a corrupted image.
Re: Error when Loading QImage
Quote:
Originally Posted by
ReginaldLarson
The error you are getting may be due to the Qt platform lacking a plugin for the format you are trying to use, or the image path may be incorrect or the image may be corrupted. Check for file path errors.
thank you :cool: