Skip to content

Commit

Permalink
Fixed issue with screenshot crash on Windows.
Browse files Browse the repository at this point in the history
Also happens on Mac, seems to be related to off-screen rendering.
  • Loading branch information
shakes76 committed Feb 29, 2016
1 parent d204d38 commit ffbd3a3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Qt/milxQtMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,13 +861,15 @@ void milxQtMain::saveScreen(QString filename)
return;

//Ensure GUI doesnt interfere
windowVTK->GetRenderWindow()->OffScreenRenderingOn();
// windowVTK->GetRenderWindow()->StereoRenderOff();
// windowVTK->GetRenderWindow()->OffScreenRenderingOn();
// windowVTK->GetRenderWindow()->SetAlphaBitPlanes(1); //Use alpha channel
windowVTK->GetRenderWindow()->Render();

windowToImage->SetInput(windowVTK->GetRenderWindow());
windowToImage->SetMagnification(magnifyFactor);
// windowToImage->SetInputBufferTypeToRGBA(); //also record the alpha (transparency) channel
windowToImage->ReadFrontBufferOff();
windowToImage->Update();

if(filename.isEmpty())
Expand All @@ -887,7 +889,7 @@ void milxQtMain::saveScreen(QString filename)
printDebug("Screenshot Size: " + QString::number(extent[1]-extent[0]) + ", " + QString::number(extent[3]-extent[2]) + ", " + QString::number(extent[5]-extent[4]));
bool success = writer->saveImage(filename, windowToImage->GetOutput());

windowVTK->GetRenderWindow()->OffScreenRenderingOff();
// windowVTK->GetRenderWindow()->OffScreenRenderingOff();
windowVTK->GetRenderWindow()->Render(); //Restore rendering

if(!success)
Expand Down

0 comments on commit ffbd3a3

Please sign in to comment.