1 #include "vtkJPEGReader.h"
2 #include "vtkImageDataGeometryFilter.h"
3 #include "vtkWarpScalar.h"
4 #include "vtkPolyDataMapper.h"
5 #include "vtkActor.h"
6 #include "vtkRenderer.h"
7 #include "vtkRenderWindow.h"
8 #include "vtkRenderWindowInteractor.h"
9
10 #define EXAMPLE_DATA "Aries.jpg" // for example -- "F:/其他/照片/Aries.jpg"
11
12 int main()
13 {
14 vtkJPEGReader *m_reader = vtkJPEGReader::New();
15 m_reader->SetFileName(EXAMPLE_DATA);
16 m_reader->Update();
17
18 vtkImageDataGeometryFilter *geo = vtkImageDataGeometryFilter::New();
19 geo->SetInput(m_reader->GetOutput());
20
21 vtkWarpScalar *scalar = vtkWarpScalar::New();
22 scalar->SetInput(geo->GetOutput());
23 scalar->SetScaleFactor(0.5);
24
25 vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
26 mapper->SetInput(scalar->GetPolyDataOutput());
27
28 vtkActor *m_Actor = vtkActor::New();
29 m_Actor->SetMapper(mapper);
30
31 vtkRenderer *m_Renderer = vtkRenderer::New();
32 m_Renderer->AddActor(m_Actor);
33 m_Renderer->SetBackground(0.1, 0.2, 0.4);
34
35 vtkRenderWindow *m_RenWin = vtkRenderWindow::New();
36 m_RenWin->AddRenderer(m_Renderer);
37 m_RenWin->SetSize(400, 400);
38
39 vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
40 iren->SetRenderWindow(m_RenWin);
41
42
43 iren->Initialize();
44 iren->Start();
45
46 m_reader->Delete();
47 geo->Delete();
48 scalar->Delete();
49 mapper->Delete();
50 m_Actor->Delete();
51 m_Renderer->Delete();
52 m_RenWin->Delete();
53 iren->Delete();
54
55
56 return 0;
57 }