1 #include "vtkAutoInit.h" 2 VTK_MODULE_INIT(vtkRenderingOpenGL2); 3 VTK_MODULE_INIT(vtkInteractionStyle); 4 5 #include <vtkPNGReader.h>//PNG读取类 6 #include <vtkImageViewer.h>//显示2D图像类 7 #include <vtkRenderWindowInteractor.h>//交互器类 8 9 int main() 10 { 11 //实例化一个对象pngReader 12 vtkPNGReader* pngReader = vtkPNGReader::New(); 13 pngReader->SetFileName("wode.png");//读取图片 14 15 //实例化一个对象pngViewer 16 vtkImageViewer* bmpViewer = vtkImageViewer::New(); 17 bmpViewer->SetInputConnection(pngReader->GetOutputPort());//读取的图像数据输出给显示对象输入 18 bmpViewer->SetColorLevel(128);//设置窗位 19 bmpViewer->SetColorWindow(256);//设置窗宽 20 bmpViewer->Render();//显示图像 21 22 //加入交互机制 23 //实例化一个交互器对象interactor 24 vtkRenderWindowInteractor* interactor = vtkRenderWindowInteractor::New(); 25 bmpViewer->SetupInteractor(interactor); 26 interactor->Initialize(); 27 interactor->Start();//使交互器处于等待状态 28 29 //getchar(); 30 //释放内存 31 pngReader->Delete(); 32 bmpViewer->Delete(); 33 interactor->Delete(); 34 35 return 0; 36 }
标签:bmpViewer,12,读取,VTK,pngReader,interactor,include,PNG From: https://www.cnblogs.com/ybqjymy/p/17628701.html