2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
4 #include "bbcreaVtkScreenShot.h"
5 #include "bbcreaVtkPackage.h"
7 #include "vtkWindowToImageFilter.h"
8 #include "vtkPNGWriter.h"
11 // #include "vtkFFMPEGWriter.h"
17 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ScreenShot)
18 BBTK_BLACK_BOX_IMPLEMENTATION(ScreenShot,bbtk::AtomicBlackBox);
20 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
22 void ScreenShot::Process()
25 // THE MAIN PROCESSING METHOD BODY
26 // Here we simply set the input 'In' value to the output 'Out'
27 // And print out the output value
28 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
29 // void bbSet{Input|Output}NAME(const TYPE&)
30 // const TYPE& bbGet{Input|Output}NAME() const
32 // * NAME is the name of the input/output
33 // (the one provided in the attribute 'name' of the tag 'input')
34 // * TYPE is the C++ type of the input/output
35 // (the one provided in the attribute 'type' of the tag 'input')
37 // bbSetOutputOut( bbGetInputIn() );
38 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
40 vtkWindowToImageFilter *wif = vtkWindowToImageFilter::New();
41 if (bbGetInputSize().size()==2)
43 bbGetInputvtkRenderer()->GetVTKWindow()->SetSize( bbGetInputSize()[0], bbGetInputSize()[1] );
45 wif->SetInput( bbGetInputvtkRenderer()->GetVTKWindow() );
46 wif->SetMagnification( bbGetInputScale()[0] );
47 // wif->SetScale( bbGetInputScale()[0], bbGetInputScale()[1] );
48 wif->SetInputBufferTypeToRGB();
49 wif->ReadFrontBufferOff();
51 vtkPNGWriter *writer = vtkPNGWriter::New();
52 writer->SetFileName( bbGetInputFileName().c_str() );
54 //EED 2017-01-01 Migration VTK7
55 #if VTK_MAJOR_VERSION <= 5
56 writer->SetInput( wif->GetOutput() );
58 writer->SetInputData( wif->GetOutput() );
65 vtkFFMPEGWriter *writer2 = vtkFFMPEGWriter::New();
66 writer2->SetInput(wif->GetOutput());
67 for (int i=0; i<10; i++)
76 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
78 void ScreenShot::bbUserSetDefaultValues()
81 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
82 // Here we initialize the input 'In' to 0
83 bbSetInputvtkRenderer(NULL);
84 bbSetInputFileName("ScreenShot-BBTK.png");
86 std::vector<int> scale;
89 bbSetInputScale(scale);
93 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
95 void ScreenShot::bbUserInitializeProcessing()
98 // THE INITIALIZATION METHOD BODY :
100 // but this is where you should allocate the internal/output pointers
106 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
108 void ScreenShot::bbUserFinalizeProcessing()
111 // THE FINALIZATION METHOD BODY :
113 // but this is where you should desallocate the internal/output pointers
118 // EO namespace bbcreaVtk