[Insight-developers] Re: PNGIO problem,

Luis Ibanez luis . ibanez at kitware . com
Fri, 02 Aug 2002 15:54:39 -0400


Hi Mark,

As you pointed out, there is an asymmetry in the
way reading and writing is managed by the IO code.

During writing the factories are not actually producing
the appropiate ImageIO object. The user has to create
explicitly the ImageIO and connect it to the ImageFileWriter
object.

See for example the following code extracted from:

Insight/Examples/PNGImageReadWrite.cxx:

------

   // Write a PNG Files
   typedef  itk::ImageFileWriter< ImageType >      FileSinkType;
   typedef  itk::PNGImageIO                        PNGWriterType;

   FileSinkType::Pointer   fileSink   = FileSinkType::New();
   PNGWriterType::Pointer  pngWriter  = PNGWriterType::New();

   fileSink->SetImageIO( pngWriter );
   fileSink->SetFilePrefix( outputFileName );
   fileSink->SetInput( fileSource->GetOutput() );
   fileSink->Write();

-------

Fixing this asymmetry should be in our list of
things-to-do for WA5.


Luis