PDA

View Full Version : jpeg quality ignored when saving to a QBuffer



hakiim35
2nd July 2010, 07:55
Hi, I am trying to make a simple image viewer which will support updating the jpeg image in a preview dialog and save the updated image to the disk. The following code block is from my updateImage method:


....................................
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);
imgOriginal->save(&buffer, "jpeg", t->getQuality());
imageCurrent.load(&buffer, "jpeg");
imageCurrent.save("C:/untitled.jpeg", "jpeg");
....................................

Whenever I move the slider which controls the quality token (between 0-100) , the updateImage method is called. But unfortunately, the updated image in the preview is always the original image, and also the saved image is always the original one.So, why does writing to a QBuffer with the quality parameter set, and reading back from the buffer not work?Thanks.

JohannesMunk
3rd July 2010, 11:05
That doesn't seem right, if you want to read from it!


buffer.open(QIODevice::WriteOnly);

And you will probably have to seek to the beginning too.

Joh