The most important thing for Graphics Input is to understand the format of the image to be output, while the basic methods are the same,
The bitmap output method is already available in the VC ++ category of this blog. This article provides a C ++ class that uses VTK to input JPG images.
# Include "vtkrenderwindow. H"
# Include "vtkwindowtoimagefilter. H"
# Include "vtkbmp writer. H"
Class cputoutimage
{
Public:
Cputoutimage ();
Virtual ~ Cputoutimage ();
Public:
Void setfile (cstring Str );
Void putoutimage (vtkrenderwindow * prenderwindow );
Public:
Cstring m_str;
// Vtkrenderwindow * prenderwindow; // enter
Vtkwindowtoimagefilter * pwindowtoimagefilter;
Vtkbmp writer * pbmpwriter;
};
Cputoutimage: cputoutimage ()
{
Pwindowtoimagefilter = vtkwindowtoimagefilter: New ();
Pbmpwriter = vtkbmp Writer: New ();
}
Cputoutimage ::~ Cputoutimage ()
{
Pwindowtoimagefilter-> Delete ();
Pbmpwriter-> Delete ();
}
Void cputoutimage: setfile (cstring Str)
{
M_str = STR;
}
Void cputoutimage: putoutimage (vtkrenderwindow * prenderwindow)
{
Pwindowtoimagefilter-> setinput (prenderwindow );
Pwindowtoimagefilter-> Update ();
Pbmpwriter-> setinputconnection (pwindowtoimagefilter-> getoutputport ());
Pbmpwriter-> setfilename (m_str );
Prenderwindow-> render ();
Pwindowtoimagefilter-> modified ();
Pbmpwriter-> write ();
}
How to use it, response button message, enter the render and print the input path of the image.
If (! M_imagepath)
{
Afxmessagebox ("Enter the path ");
}
M_getpath.getwindowtext (m_imagepath );
M_mange.putoutimage (m_imagepath );