PDA

View Full Version : const char* QImage Format?



grabalon
12th May 2010, 19:01
I'm trying to load an image that has no header to determine type.
How do I specify what format I want?

QString path = "..."
QImage* myVar = new QImage(path, (char *)QImage::Format_RGB32);

Causes a seg fault

Please help.

grabalon
12th May 2010, 21:45
--Solved--

Here's how I found to make it work:

QString path = "..."
QImage* myVar = new QImage(path, "PNG");
QImage* var2 = myVar->convertToFormat(QImage::Format_RGB32, Qt::ThresholdDither));


It may look wasteful, but I needed the second copy anyway. For anyone else stuck, there you go.

wysota
13th May 2010, 00:44
But this suggests your image has a PNG header... If you have only the raw data, you should use QImage::loadFromData().