From 39be00ee8c56b327079517010df2b2e575ff1fe5 Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 29 Jan 2009 13:51:24 +0000 Subject: [PATCH] Fixed a problem with performing of dumpView() in the background mode. --- src/SVTK/SVTK_ViewWindow.cxx | 26 ++++++++++++++++++++++---- src/SVTK/SVTK_ViewWindow.h | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index e6ef8c945..b5b67ddc7 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -819,13 +819,32 @@ void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor, emit actorRemoved(theActor); } +QImage SVTK_ViewWindow::dumpViewContent() +{ + vtkRenderWindow* aWindow = getRenderWindow(); + int* aSize = aWindow->GetSize(); + int aWidth = aSize[0]; + int aHeight = aSize[1]; + + unsigned char *aData = + aWindow->GetRGBACharPixelData( 0, 0, aWidth-1, aHeight-1, 0 ); + + QImage anImage( aData, aWidth, aHeight, QImage::Format_ARGB32 ); + + anImage = anImage.rgbSwapped(); + anImage = anImage.mirrored(); + return anImage; +} + /*! \return QImage, containing all scene rendering in window */ QImage SVTK_ViewWindow::dumpView() { - QPixmap px = QPixmap::grabWindow( GetInteractor()->winId() ); - return px.toImage(); + if( myDumpImage.isNull() ) + return dumpViewContent(); + + return myDumpImage; } QString SVTK_ViewWindow::filter() const @@ -872,8 +891,7 @@ bool SVTK_ViewWindow::dumpViewToFormat( const QImage& img, const QString& fileNa */ void SVTK_ViewWindow::RefreshDumpImage() { - QPixmap px = QPixmap::grabWindow( GetInteractor()->winId() ); - myDumpImage = px.toImage(); + myDumpImage = dumpViewContent(); } /*! diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index a648fc345..3a07a757c 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -348,6 +348,8 @@ protected: void doSetVisualParameters( const QString& ); void SetEventDispatcher(vtkObject* theDispatcher); + QImage dumpViewContent(); + virtual QString filter() const; virtual bool dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format ); -- 2.39.2