[Interest] QGraphicsScene and writing to file

Konstantin Tokarev annulen at yandex.ru
Thu Sep 29 16:23:43 CEST 2016



29.09.2016, 00:32, "Petric Frank" <pfrank at gmx.de>:
> Hello,
>
> i have a QGraphicsScenewhich i want to write to a file (*.png, ...).
>
> As documrmtation states i use the following:
>
> ------------------- cut ---------------------------
>
> QGraphicsScene scene; // previously filled
>
> QRectF rect = scene->sceneRect ();
>
> QImage img (rect.width () + 1, rect.height () + 1, QImage::Format_ARGB32);
>
> img.fill (QColor (Qt::white).rgb ());
>
> QPainter p (&img);
>
> scene->render (&p);
>
> p.end ();
>
> img.save ("pict.png");
>
> ------------------- cut ---------------------------
>
> But this does not work for bigger pictures. No error message. The viewer simply tells that the generated *.png file are corrupted.
> The scenes reqire a width of about 100000 pixels.
>
> After some searching in the web i found out the QImage (and QPixmap) seems to have an internal limitation of about 32k x 32k.
>
> The PNG-format does not have such a limitation.
>
> Any hints on how to export such a big scene to a PNG (or other) file ?
>
> Currently i use Qt 5.6.1 (Linux 64 Bit) and Qt 5.2 (Windows 7 64 Bit).
>
> Both hosts have 16 GB main memory.
>

IMO, PNG format is just not appropriate for dealing data like this. How are you going to process/visualize it later? I guess you need more scalable format, like JPEG2000.


> kind regards
>
> Petric
>
> ,
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-- 
Regards,
Konstantin



More information about the Interest mailing list