TuttleOFX
1
|
00001 #include "ConstantProcess.hpp" 00002 00003 #include <tuttle/plugin/ofxToGil/point.hpp> 00004 #include <terry/algorithm/transform_pixels_progress.hpp> 00005 #include <terry/numeric/assign.hpp> 00006 00007 #include <boost/numeric/conversion/cast.hpp> 00008 00009 namespace tuttle { 00010 namespace plugin { 00011 namespace constant { 00012 00013 template<class View> 00014 ConstantProcess<View>::ConstantProcess( ConstantPlugin& instance ) 00015 : ImageGilProcessor<View>( instance, eImageOrientationIndependant ) 00016 , _plugin( instance ) {} 00017 00018 template<class View> 00019 ConstantParams<View> ConstantProcess<View>::getParams() 00020 { 00021 using namespace boost::gil; 00022 ConstantParams<View> params; 00023 00024 OfxRGBAColourD c = _plugin._color->getValue(); 00025 color_convert( rgba32f_pixel_t( c.r, c.g, c.b, c.a ), params._color ); 00026 return params; 00027 } 00028 00029 template<class View> 00030 void ConstantProcess<View>::setup( const OFX::RenderArguments& args ) 00031 { 00032 ImageGilProcessor<View>::setup( args ); 00033 00034 // params 00035 _params = getParams(); 00036 } 00037 00038 /** 00039 * @brief Function called by rendering thread each time a process must be done. 00040 * @param[in] procWindowRoW Processing window in RoW 00041 */ 00042 template<class View> 00043 void ConstantProcess<View>::multiThreadProcessImages( const OfxRectI& procWindowRoW ) 00044 { 00045 using namespace boost::gil; 00046 const OfxRectI procWindowOutput = this->translateRoWToOutputClipCoordinates( procWindowRoW ); 00047 const OfxPointI procWindowSize = { 00048 procWindowRoW.x2 - procWindowRoW.x1, 00049 procWindowRoW.y2 - procWindowRoW.y1 }; 00050 00051 View dst = subimage_view( this->_dstView, 00052 procWindowOutput.x1, procWindowOutput.y1, 00053 procWindowSize.x, procWindowSize.y ); 00054 00055 terry::algorithm::transform_pixels_progress( 00056 dst, 00057 terry::numeric::pixel_assigns_color_t<Pixel>( _params._color ), 00058 this->getOfxProgress() 00059 ); 00060 } 00061 00062 } 00063 } 00064 }