一、前提
VTK安装完毕
二、创建
建立文件夹:mkdir jpgexample
cd jpgexample
vi jpg.cxx
code:
1 #include "vtkQuadraticHexahedron.h"
2 #include "vtkUnstructuredGridReader.h"
3 #include "vtkMapper.h"
4 #include "vtkBMPReader.h"
5 #include "vtkTexture.h"
6 #include "vtkUnstructuredGridSource.h"
7 #include "vtkUnstructuredGrid.h"
8 #include "vtkProperty.h"
9 #include "vtkDataSetMapper.h"
10 #include "vtkLight.h"
11 #include "vtkCamera.h"
12 #include "vtkUnstructuredGridWriter.h"
13 #include "vtkPolyDataMapper.h"
14 #include "vtkActor.h"
15 #include "vtkRenderWindow.h"
16 #include "vtkRenderer.h"
17 #include "vtkRenderWindowInteractor.h"
18 #include "vtkInteractorStyleTrackballCamera.h"
19 #include "vtkCallbackCommand.h"
20 #include "vtkCamera.h"
21
22 #include "vtkJPEGReader.h"
23 #include "vtkInteractorStyleImage.h"
24 #include "vtkImageActor.h"
25
26 #define EXAMPLE_FILE "/home/Pictures/*.jpg"
27
28 int main(int argc, char **argv)
29 {
30
31 vtkJPEGReader *m_reader = vtkJPEGReader::New();
32 m_reader->SetFileName(EXAMPLE_FILE);
33
34 vtkImageActor *m_Actor = vtkImageActor::New();
35 m_Actor->SetInput(m_reader->GetOutput());
36
37 vtkRenderer *m_Renderer = vtkRenderer::New();
38 m_Renderer->AddActor(m_Actor);
39
40 vtkRenderWindow *m_RenWin = vtkRenderWindow::New();
41 m_RenWin->AddRenderer(m_Renderer);
42 m_RenWin->SetSize(800, 800);
43
44 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
45 iren->SetRenderWindow(m_RenWin);
46
47 iren->Initialize();
48 iren->Start();
49
50 m_reader->Delete();
51 m_Actor->Delete();
52 m_Renderer->Delete();
53 m_RenWin->Delete();
54 iren->Delete();
55 return 0;
56 }
vi CMakeLists.txt
code:
1 PROJECT (Step1)
2
3 IF(NOT VTK_BINARY_DIR)
4 FIND_PACKAGE(VTK REQUIRED)
5 IF(NOT VTK_USE_RENDERING)
6 MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
7 ENDIF(NOT VTK_USE_RENDERING)
8 INCLUDE(${VTK_USE_FILE})
9 ENDIF(NOT VTK_BINARY_DIR)
10
11 ADD_EXECUTABLE(Jpg jpg.cxx)
12 TARGET_LINK_LIBRARIES(Jpg vtkRendering)
三、编译
ccmake ./
cmake ./
make
./Jpg
阅读(6315) | 评论(1) | 转发(0) |