-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpng_reader.cpp
36 lines (29 loc) · 946 Bytes
/
png_reader.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "vtkImageActor.h"
#include "vtkImageMapper3D.h"
#include "vtkInteractorStyleImage.h"
#include "vtkNew.h"
#include "vtkPNGReader.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "platform.h"
auto main(int argc, char** argv) -> int {
const auto file_name{
fs::current_path().append("Data/BlueCircle.png").string()};
vtkNew<vtkPNGReader> reader;
reader->SetFileName(file_name.c_str());
reader->Update();
vtkNew<vtkImageActor> actor;
actor->GetMapper()->SetInputConnection(reader->GetOutputPort());
vtkNew<vtkRenderer> render;
render->AddActor(actor);
vtkNew<vtkRenderWindow> window;
window->AddRenderer(render);
vtkNew<vtkInteractorStyleImage> style;
vtkNew<vtkRenderWindowInteractor> interacotr;
interacotr->SetRenderWindow(window);
interacotr->SetInteractorStyle(style);
window->Render();
interacotr->Initialize();
interacotr->Start();
}