image_fileoutput.h

Go to the documentation of this file.
00001 #ifndef IMAGE_FILEOUTPUT_H
00002 #define IMAGE_FILEOUTPUT_H
00003 
00004 #include <iostream>
00005 #include <list>
00006 #include <Magick++.h>
00007 #include <map>
00008 #include "image_output.h"
00009 #include "rgba.h"
00010 
00011 namespace mimas {
00012 
00038 template< typename T >
00039 class image_fileoutput: public image_output< T >
00040 {
00041  public:
00044   explicit image_fileoutput( std::ostream &_stream ): stream( &_stream ) {}
00047   virtual ~image_fileoutput(void);
00050   virtual void write( const const_image_ref< T > &image );
00055   static std::map< std::string, bool > formats(void);
00056  protected:
00060   static const char *mapString(void);
00064   static const char *defaultFormat(void);
00066   std::ostream *stream;
00068   std::list< Magick::Image > buffer;
00069 };
00070 
00071 template<>
00072 const char *image_fileoutput< unsigned char >::mapString(void);
00073 
00074 template<>
00075 const char *image_fileoutput< rgba< unsigned char > >::mapString(void);
00076 
00077 template<>
00078 const char *image_fileoutput< unsigned char >::defaultFormat(void);
00079 
00080 template<>
00081 const char *image_fileoutput< rgba< unsigned char > >::defaultFormat(void);
00082 
00084 extern const char *image_fileoutput_fileType;
00085 
00087 struct _format { const char *name; };
00094 inline _format setformat( const char *name )
00095 { _format retVal; retVal.name = name; return retVal; }
00096 
00100 inline std::ostream &operator<<( std::ostream &stream, _format format )
00101 { image_fileoutput_fileType = format.name; return stream; }
00102 
00104 template< typename T, typename U >
00105 inline image_fileoutput< T > &operator<<( image_fileoutput< T > &output,
00106                                           const const_image_ref< U > &im )
00107 {
00108   if ( typeid( T ) == typeid( U ) )
00109     output.write( (const_image_ref< T > &)im );
00110   else {
00111     output.write( image< T >( im ) );
00112   };
00113   return output;
00114 }
00115 
00117 inline std::ostream &operator<<( std::ostream &stream,
00118                                  const const_image_ref< unsigned char > &img )
00119 {
00120   image_fileoutput< unsigned char > output( stream );
00121   output << img;
00122   return stream;
00123 }
00124 
00126 inline std::ostream &operator<<( std::ostream &stream,
00127                                  const const_image_ref< int > &img )
00128 {
00129   image_fileoutput< unsigned char > output( stream );
00130   output << img;
00131   return stream;
00132 }
00133 
00135 inline std::ostream &operator<<( std::ostream &stream,
00136                                  const const_image_ref< double > &img )
00137 {
00138   image_fileoutput< unsigned char > output( stream );
00139   output << img;
00140   return stream;
00141 }
00142 
00144 inline std::ostream &operator<<( std::ostream &stream,
00145                                  const const_image_ref< float > &img )
00146 {
00147   image_fileoutput< unsigned char > output( stream );
00148   output << img;
00149   return stream;
00150 }
00151 
00153 inline std::ostream &operator<<( std::ostream &stream,
00154                                  const const_image_ref< rgba< unsigned char > > &img )
00155 {
00156   image_fileoutput< rgba< unsigned char > > output( stream );
00157   output << img;
00158   return stream;
00159 }
00160 
00162 inline std::ostream &operator<<( std::ostream &stream,
00163                                  const const_image_ref< rgba< int > > &img )
00164 {
00165   image_fileoutput< rgba< unsigned char > > output( stream );
00166   output << img;
00167   return stream;
00168 }
00169 
00171 inline std::ostream &operator<<( std::ostream &stream,
00172                                  const const_image_ref< rgba< float > > &img )
00173 {
00174   image_fileoutput< rgba< unsigned char > > output( stream );
00175   output << img;
00176   return stream;
00177 }
00178 
00180 inline std::ostream &operator<<( std::ostream &stream,
00181                                  const const_image_ref< rgba< double > > &img )
00182 {
00183   image_fileoutput< rgba< unsigned char > > output( stream );
00184   output << img;
00185   return stream;
00186 }
00187 
00189 
00191 
00192 };
00193 
00194 #include "image_fileoutput.tcc"
00195 
00196 #endif

[GNU/Linux] [Qt] [Mesa] [STL] [Lapack] [Boost] [Magick++] [Xalan-C and Xerces-C] [doxygen] [graphviz] [FFTW] [popt] [xine] [Gnuplot] [gnu-arch] [gcc] [gstreamer] [autoconf/automake/make] [freshmeat.net] [opensource.org] [sourceforge.net] [MMVL]
mimas 2.1 - Copyright Mon Oct 30 11:31:17 2006, Bala Amavasai, Stuart Meikle, Arul Selvan, Fabio Caparrelli, Jan Wedekind, Manuel Boissenin, ...