PDA

View Full Version : Maximum PNG dimensions?



blooglet
1st May 2011, 20:51
I've noticed that if I try to export a QGraphicsScene to a PNG that is over 10000x10000 in size, no PNG file is written to disk. Do PNG files have a maximum width/height?

minirop
1st May 2011, 23:03
the width/height of a PNG file is written on 4 bytes, the problem is elsewhere. not enough memory ? the way Qt writes pictures ? something else ?

ChrisW67
2nd May 2011, 04:11
A 32-bits-per-pixel, 10000 by 10000 pixel image will require at least 400 million bytes of RAM to represent uncompressed in memory. Typically this image buffer would need to allocated in a contiguous block which could be difficult. Such an image will need to exist before it can be coded and compressed into PNG form.

blooglet
2nd May 2011, 11:52
Typically this image buffer would need to allocated in a contiguous block which could be difficult.
Does this fail without a warning? My export instructions execute fine in all cases, but if the image is too big no file is written. Is there a proper way to check if the export failed or do I just check if the file exists on the disk?

ChrisW67
3rd May 2011, 03:03
None that I have found. On my Linux machine attempting to create a 100k by 100k QPixmap generates an error message to the console from the underlying X library but nonetheless returns a QPixmap with the requested size and isNull() == false.

mcosta
3rd May 2011, 09:34
If you use QGraphicsScene::render() you can use the second parameter to scale the scene on Pixmap

blooglet
5th May 2011, 08:49
None that I have found. On my Linux machine attempting to create a 100k by 100k QPixmap generates an error message to the console from the underlying X library but nonetheless returns a QPixmap with the requested size and isNull() == false.
Good that you mention that... I found out that if I check against QImage::isNull, I can see when things go wrong. isNull() returns true whenever the image is too big for export, so now I can detect when the export fails. Thanks!