+ // Video
+ vtkGenericMovieWriter *vidwriter = NULL;
+#if CLITK_EXPERIMENTAL == 1
+ if (ext==".gif") {
+ vvAnimatedGIFWriter *gif = vvAnimatedGIFWriter::New();
+ vidwriter = gif;
+
+ // FPS
+ bool ok;
+ int fps = QInputDialog::getInteger(this, tr("Number of frames per second"),
+ tr("FPS:"), 5, 0, 1000, 1, &ok);
+ if(ok)
+ gif->SetRate(fps);
+
+ // Loops
+ int loops = QInputDialog::getInteger(this, tr("Loops"),
+ tr("Number of loops (0 means infinite):"), 0, 0, 1000000000, 1, &ok);
+ if(ok)
+ gif->SetLoops(loops);
+
+ // Dithering
+ QString msg = "Would you like to activate dithering?";
+ QMessageBox msgBox(QMessageBox::Question, tr("Dithering"),msg, 0, this);
+ msgBox.addButton(tr("Yes"), QMessageBox::AcceptRole);
+ msgBox.addButton(tr("No"), QMessageBox::RejectRole);
+ gif->SetDither(msgBox.exec() == QMessageBox::AcceptRole);
+ }
+#endif
+#ifdef VTK_USE_VIDEO_FOR_WINDOWS
+ if (ext==".avi") {
+ vtkAVIWriter *mpg = vtkAVIWriter::New();
+ vidwriter = mpg;
+ mpg->SetQuality(2);
+ bool ok;
+ int fps = QInputDialog::getInteger(this, tr("Number of frames per second"),
+ tr("FPS:"), 5, 0, 1024, 1, &ok);
+ if(!ok)
+ fps = 5;
+ mpg->SetRate(fps);
+ }
+#endif
+#ifdef VTK_USE_FFMPEG_ENCODER
+ if (ext==".avi") {
+ vtkFFMPEGWriter *mpg = vtkFFMPEGWriter::New();
+ vidwriter = mpg;
+ mpg->SetQuality(2);
+ bool ok;
+ int fps = QInputDialog::getInteger(this, tr("Number of frames per second"),
+ tr("FPS:"), 5, 0, 1024, 1, &ok);
+ if(!ok)
+ fps = 5;
+ mpg->SetRate(fps);
+ mpg->SetBitRateTolerance(int(ceil(12.0*1024*1024/fps)));
+ }
+#endif
+#ifdef VTK_USE_MPEG2_ENCODER
+ if (ext==".mpg") {
+ vtkMPEG2Writer *mpg = vtkMPEG2Writer::New();
+ vidwriter = mpg;
+ }
+#endif
+
+ // Take video if not null
+ if(vidwriter!=NULL){
+ vidwriter->SetInput(image);
+ vidwriter->SetFileName(fileName.toStdString().c_str());
+ vidwriter->Start();
+ vvImage * vvImg = mSlicerManagers[smIndex]->GetImage();
+ int nSlice = vvImg->GetVTKImages().size();
+ for(int i=0; i<nSlice; i++) {
+ mSlicerManagers[smIndex]->SetNextTSlice(0);
+ vtkSmartPointer<vtkWindowToImageFilter> w2i = vtkSmartPointer<vtkWindowToImageFilter>::New();
+ w2i->SetInput(widget->GetRenderWindow());
+ w2i->Update();
+ vidwriter->SetInput(w2i->GetOutput());
+ vidwriter->Write();
+ }
+ vidwriter->End();
+ vidwriter->Delete();
+ return;
+ }
+
+ QMessageBox::information(this,tr("Problem saving screenshot !"),tr("Cannot save image.\nPlease set a file extension !!!"));
+ }