[vtkusers] Rendering QVTKWidget into QPixmap
Julien Finet
julien.finet at kitware.com
Wed Feb 8 09:18:42 EST 2012
Hi Christian,
Here is what we do in CTK to grab a QVTKWidget:
https://github.com/commontk/CTK/blob/master/Libs/Visualization/VTK/Widgets/ctkVTKWidgetsUtils.cpp
Please note that it means that QVTKWidget::cachedImage must be turned on.
Hth,
Julien.
On Wed, Feb 8, 2012 at 7:16 AM, Christian Lackas <lackas at invicro.com> wrote:
> Hi Everybody,
>
> we are using VTK in a Qt-based application of ours and employ QVTKWidget
> for this. To allow the user to store rendered data as images, we use
> code such as:
>
> class VRenderer: public QVTKWidget {
> Q_OBJECT
> public:
> ...
> QPixmap grabImage() {
> QPixmap pixmap( size() );
> render( &pixmap );
> return pixmap;
> }
> ...
> };
>
> and then use the QPixmap object to produce an image file (which aligns
> well with our non-VTK-based rendering widgets).
> On Mac OS X, as well as Linux and many Windows systems this does work
> pretty well. Unfortunately, we do have a couple of Windows system
> (Vista, 7, 32- and 64-bit, but not consistently on one platform) where
> above code produces merely an all-black image.
> I assume this has something to do with how the graphic card driver
> handles the OpenGL drawing (or something along this line, e.g.
> asynchronous processing, where we grab the image to early, etc...).
>
> I already tried using functions such as
> vtkRenderWindow::WaitForCompletion(),
> however, as the documentation suggest that was not useful here, calling
> vtkRenderWindow::Render() explicitly myself, etc...
>
> Is there a way to make sure that a QVTKWidget renders and actual image
> into my pixmap?
>
> Or should I start using vtkRenderWindow::GetRGBAPixelData() instead?
>
> Thanks for any hints.
> Christian
>
> --
> http://www.invicro.com/ http://www.spect-ct.com/
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120208/eee91ab9/attachment.htm>
More information about the vtkusers
mailing list