Qt QImage how to display truncated png file?

341 Views Asked by At

I am trying to read an image into a QImage from a partially downloaded file, to show progress as it downloads. With jpg images, I can display the content that has downloaded so far, but with png files I get the following error:

libpng error: Read Error

and then trying to use the QImage results in failure with:

Image is a null image

If I save the partially downloaded file, I can open it with every program I've tried, showing though sometimes logging a warning, like with gimp:

* (file-png:25459): WARNING **: Error loading PNG file: Read Error

Is there a way to get the same behavior with png's as with jpg's where the partially downloaded file is loaded and displayed as just the top half of the image? Is there a better way to do this with QImage? I have access to the image data in RAM as well, plus the length of how much has been received, if that helps.

0

There are 0 best solutions below