[Qt-interest] Saving image rendered in openGL widget in different resolutions
Fabio Dago
fabio.dago at sir.to.it
Tue Feb 17 08:50:29 CET 2009
I don't know how you render the scene, so I can only suppose...
Maybe you render the scene with a display list... If so, read the
documentation of
QPixmap QGLWidget::renderPixmap( int w = 0, int h = 0, bool useContext = false )
in particular:
"Note that the creation of display lists, modifications of the view frustum etc. should be done from within initializeGL <qglwidget.html#initializeGL>(). If this is not done, the temporary QGLContext <qglcontext.html> will not be initialized properly, and the rendered pixmap may be incomplete/corrupted."
This because, for render in pixmap, another context is created, so you
must setup the scene, the view frustum etc. from within initializeGL().
If the problem isn't this, I don't know how help you...
Regards.
Fabio.
anjani gupta ha scritto:
>
> Hi,
>
> I tried using QGLWidget::renderPixmap( ), but I am getting black
> image, it does not display rendered widgets.
>
> Code snippet:
> <code>
> QGLWidget* main_window;
> //Assign value to main_window
> ...
> main_window->raise();
> main_window->repaint();
> QPixmap image = main_window->renderPixmap(800,600);
> image.save("filename","JPG"));
> </code>
>
> This saves an empty black image in 'filename.jpg'
> Thanks in advance!
>
> Regards,
> Anjani
>
>
>
> --- On *Fri, 2/13/09, Fabio Dago /<fabio.dago at sir.to.it>/* wrote:
>
> From: Fabio Dago <fabio.dago at sir.to.it>
> Subject: Re: [Qt-interest] Saving image rendered in openGL widget
> in different resolutions
> To: anjanigupta_dce at yahoo.com, qt-interest at trolltech.com
> Date: Friday, February 13, 2009, 9:02 PM
>
> You can use this:
>
> QPixmap QGLWidget::renderPixmap <qglwidget.html#renderPixmap> ( int w =
> 0, int h = 0, bool useContext = false )
>
> Regards.
>
> Fabio
>
> anjani gupta ha scritto:
> > Hi,
> > I want to save openGL image rendered on main window in different file
> formats with different resolutions.
> > To save image in different format, I am using the following code:
> > <code>
> > QGLWidget* main_window;
> > //Assign value to main_window
> > ...
> > main_window->raise();
> > main_window->repaint();
> > QPixmap image = QPixmap::grabWindow(main_window->winId());
> > image.save("filename","TIF"));
> > </code>
> > I want to save image in different resolutions.Is there some efficient way
> to save image in different resolutions?
> > Thanks in
> advance!
> > Regards,
> > Anjani
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at trolltech.com
> > http://lists.trolltech.com/mailman/listinfo/qt-interest
> > ------------------------------------------------------------------------
> >
> >
> > No virus found in this incoming message.
> > Checked by AVG - www.avg.com Version: 8.0.234 / Virus Database:
> 270.10.23/1948 - Release Date: 02/12/09 07:20:00
> >
> >
>
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.0.237 / Virus Database: 270.10.24/1954 - Release Date: 02/15/09 18:09:00
>
>
More information about the Qt-interest-old
mailing list