saving QPixmap to QIODevice gives SEGV error
Hello all,
I am trying to capture a screenshot of my Application in a QPixmap and then save it to a QIODevice. But it's giving segmentation fault.
Not able to figure out why.
Here's the code-
Code:
ui.myLabel->setPixmap(pix); //This is fine. Displays the Screenshot
ui.myLabel->setScaledContents(true);
qDebug()<<"before";
pix.save(&buffer); //Gives SEGV Error
qDebug()<<"after";
buffer.close();
Not able to figure out what the problem is. :(
Re: saving QPixmap to QIODevice gives SEGV error
You haven't given a format in the save() call. Try using something like "PNG" as the second parameter.
Re: saving QPixmap to QIODevice gives SEGV error
Quote:
Originally Posted by
d_stranz
Try using something like "PNG" as the second parameter.
Thanks a lot. That solved the issue but now I am facing another issue.
After saving the image file in PNG format, I am trying to read the same file in another application and again save it in another name. (Extremely sorry if it sounds strange but please bear with me :rolleyes: ) It's crashing.
The first app-
Code:
QImage img
= pix.
toImage();
//Converting to QImage so that I can know which format it is in.
qDebug()<<"size: "<<img.size();
qDebug()<<"format: "<<img.format(); //returns QImage::Format_RGB16
img.save("/pefis/bin/test.png", "PNG"); //This works fine
In another app-
Code:
QImage img
("/pefis/bin/test.png",
"PNG");
qDebug()<<"size: "<<img.size();
qDebug()<<"format: "<<img.format(); //returns QImage::Format_RGB32
img.save("/pefis/bin/test1.png", "PNG"); //Crashes here. Gives SEGV Error
First the Image format is automatically changing and then it is crashing when I am trying to save it in another name.
Please point out what mistake I am committing.
-Thanking You,
sattu