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() );
53 writer->SetInput(wif->GetOutput());
57 vtkFFMPEGWriter *writer2 = vtkFFMPEGWriter::New();
58 writer2->SetInput(wif->GetOutput());
59 for (int i=0; i<10; i++)
68 // 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)
70 void ScreenShot::bbUserSetDefaultValues()
73 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
74 // Here we initialize the input 'In' to 0
75 bbSetInputvtkRenderer(NULL);
76 bbSetInputFileName("ScreenShot-BBTK.png");
78 std::vector<int> scale;
81 bbSetInputScale(scale);
85 // 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)
87 void ScreenShot::bbUserInitializeProcessing()
90 // THE INITIALIZATION METHOD BODY :
92 // but this is where you should allocate the internal/output pointers
98 // 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)
100 void ScreenShot::bbUserFinalizeProcessing()
103 // THE FINALIZATION METHOD BODY :
105 // but this is where you should desallocate the internal/output pointers
110 // EO namespace bbcreaVtk