PDA

View Full Version : Saving image fails on other machines



27Loco
28th July 2010, 10:31
Hello,

I already added the plugins qgif4.dll, qjpeg4.dll and qtiff4.dll and called in the main method QApplication::addLibraryPath. The application now successfully loads images and tells me that the following formats are supported.

bmp, jpeg, jpg, png, ppm, tif, tiff, xbm, xpm

But saving works only on my development machine. This is what I am doing in order to save an image:


QPainter *painter = new QPainter();
QRectF rect = scene->itemsBoundingRect();

QImage *image = new QImage(rect.size().toSize(), QImage::Format_ARGB32_Premultiplied);

painter->begin(image);
scene->render(painter);
painter->end();

image->save("test.jpg", "JPG");

delete painter;
delete image;

What am I doing wrong?

Thanks for your support.

Lykurg
28th July 2010, 14:49
Have you tried to save it with PNG or any other format? If that works, you have done something wrong with the plugins. Normally you don't need to call addLibrary.

27Loco
28th July 2010, 14:52
I already tried png, bmp and jpg, but none of them works on other machines, only on my development pc.

Loading images worked after using the plugins so I guess the plugins work well.

grabalon
28th July 2010, 18:25
Try removing the format from the save call, and letting Qt figure it out on its own:


image->save("test.jpg");

27Loco
28th July 2010, 18:34
Doesnt work either.

I activated the console and now I got some more information about the problem. This is what I get when I am trying to save the image.

QPainter::begin: Paint device returned engine == 0, type: 3;
QPainter::save: Painter not active
QPainter::setClipRect: Painter not active
QPainter::restore: Unbelanced save/restore
.
.
.
.
QPainter::end: Painter not active, aborted

SOLVED
rect.size().toSize() was the problem. The size was not valid and therefore the image was invalid. So many hours :(

Thanks for your help