TuttleOFX
1
|
00001 #include "ImageMagickWriterDefinitions.hpp" 00002 #include "ImageMagickWriterPlugin.hpp" 00003 00004 #include <terry/globals.hpp> 00005 #include <tuttle/plugin/exceptions.hpp> 00006 00007 #include <boost/gil/gil_all.hpp> 00008 #include <boost/scoped_ptr.hpp> 00009 #include <boost/filesystem/fstream.hpp> 00010 00011 namespace tuttle { 00012 namespace plugin { 00013 namespace imagemagick { 00014 namespace writer { 00015 00016 template<class View> 00017 ImageMagickWriterProcess<View>::ImageMagickWriterProcess( ImageMagickWriterPlugin& instance ) 00018 : ImageGilFilterProcessor<View>( instance, eImageOrientationFromTopToBottom ) 00019 , _plugin( instance ) 00020 { 00021 this->setNoMultiThreading(); 00022 } 00023 00024 /** 00025 * @brief Function called by rendering thread each time a process must be done. 00026 * @param[in] procWindowRoW Processing window in RoW 00027 * @warning no multithread here ! 00028 */ 00029 template<class View> 00030 void ImageMagickWriterProcess<View>::multiThreadProcessImages( const OfxRectI& procWindowRoW ) 00031 { 00032 BOOST_ASSERT( procWindowRoW == this->_srcPixelRod ); 00033 using namespace boost::gil; 00034 ImageMagickWriterProcessParams params = _plugin.getProcessParams( this->_renderArgs.time ); 00035 try 00036 { 00037 writeImage<bits8>( this->_srcView, params._filepath ); 00038 } 00039 catch( exception::Common& e ) 00040 { 00041 e << exception::filename( params._filepath ); 00042 throw; 00043 } 00044 catch(... ) 00045 { 00046 BOOST_THROW_EXCEPTION( exception::Unknown() 00047 << exception::user( "Unable to write image") 00048 << exception::dev( boost::current_exception_diagnostic_information() ) 00049 << exception::filename(params._filepath) ); 00050 } 00051 copy_pixels( this->_srcView, this->_dstView ); /// @todo ? 00052 } 00053 00054 /** 00055 * 00056 */ 00057 template<class View> 00058 template<class Bits> 00059 void ImageMagickWriterProcess<View>::writeImage( View& src, const std::string& filepath ) 00060 { 00061 using namespace boost::gil; 00062 00063 // if( params._premult ) 00064 // { 00065 // typedef pixel<Bits, rgb_layout_t> OutPixelType; 00066 // imagemagick_write_view( filepath, flipped_up_down_view( color_converted_view<OutPixelType>( src ) ), params._quality ); 00067 // } 00068 // else 00069 // { 00070 // typedef pixel<Bits, layout<typename color_space_type<View>::type> > OutPixelType; 00071 // imagemagick_write_view( filepath, flipped_up_down_view( color_converted_view<OutPixelType>( src ) ) ); 00072 // } 00073 } 00074 00075 } 00076 } 00077 } 00078 }