[vtkusers] vtkImageWriter issue...
Hal Canary
hal at cs.unc.edu
Mon May 21 14:03:01 EDT 2012
I still think you have to choose a class at some point. You can keep
the pointer as a vtkImageWriter pointer and use polymorphism:
vtkSmartPointer<vtkImageWriter> writer;
switch (file_type)
{
case JPEG:
writer = vtkSmartPointer<vtkJPEGWriter>::New();
break;
case PNG:
writer = vtkSmartPointer<vtkPNGWriter>::New();
break;
default:
writer = vtkSmartPointer<vtkTIFFWriter>::New();
}
writer->SetInput(vtkVolume);
writer->SetFileName(filename);
writer->Write();
On 5/21/2012 11:07 AM, Ale wrote:
> I try to use the vtkImageWriter because, in future, I'd like to set
> the file type as one among the supported types... Is it wrong?
>
> Il giorno 21/mag/2012, alle ore 16.52, Hal Canary ha scritto:
> >
> > If you want to write a .tif file, why don't you call
> > vtkSmartPointer<vtkTIFFWriter>::New() ?
> >
> > On 05/21/2012 06:54 AM, Ale wrote:
> > > Hello,
> > >
> > > I'd like to write an vtkImageData into a file (in order to check
> > > if a correctly made the import from ITK). I use VTK 5.10 under
> > > OSX and QT. I resort to this code (where vtkVolume is a
> > > vtkSmartPointer<vtkImageData> correctly instatiated):
> > >
> > > vtkSmartPointer<vtkImageWriter> writer
> > > = vtkSmartPointer<vtkImageWriter>::New();
> > > writer->SetInput(vtkVolume);
> > > writer->SetFileName ("/mydir/filename.tif");
> > > writer->Write();
> > >
> > > When the program is run I get the program exit unexpected with
> > > this (portion) error:
> > > [...]
> > >
> > > Thanks,
> > > Ale
--
Hal Canary
More information about the vtkusers
mailing list