TuttleOFX
1
|
00001 #include "ColorBarsProcess.hpp" 00002 00003 #include <tuttle/plugin/ofxToGil/point.hpp> 00004 00005 #include <boost/numeric/conversion/cast.hpp> 00006 00007 namespace tuttle { 00008 namespace plugin { 00009 namespace colorBars { 00010 00011 template<class View> 00012 ColorBarsProcess<View>::ColorBarsProcess( ColorBarsPlugin &instance ) 00013 : ImageGilProcessor<View>( instance, eImageOrientationFromBottomToTop ) 00014 , _plugin( instance ) 00015 { 00016 } 00017 00018 template<class View> 00019 void ColorBarsProcess<View>::setup( const OFX::RenderArguments& args ) 00020 { 00021 using namespace boost::gil; 00022 ImageGilProcessor<View>::setup( args ); 00023 00024 00025 boost::function_requires<PixelLocatorConcept<Locator> >(); 00026 gil_function_requires < StepIteratorConcept<typename Locator::x_iterator> >(); 00027 00028 OfxRectD rod = _plugin._clipDst->getCanonicalRod( args.time ); 00029 00030 Point dims( rod.x2 - rod.x1, rod.y2 - rod.y1 ); 00031 00032 ColorBarsParams params = _plugin.getProcessParams(); 00033 00034 // create a squared view 00035 ColorBarsVirtualView colorbars( Point( 1, 1 ), Locator( Point( 0, 0 ), Point( 1, 1 ), ColorBarsFunctorT( dims.x, params.mode == eColorBarsLevels75 ) ) ); 00036 // create a subview depending on the image ratio 00037 _srcView = subimage_view<>( colorbars, 0, 0, boost::numeric_cast<int>( dims.x ), boost::numeric_cast<int>( dims.y ) ); 00038 00039 } 00040 00041 /** 00042 * @brief Function called by rendering thread each time a process must be done. 00043 * @param[in] procWindowRoW Processing window 00044 */ 00045 template<class View> 00046 void ColorBarsProcess<View>::multiThreadProcessImages( const OfxRectI& procWindowRoW ) 00047 { 00048 using namespace boost::gil; 00049 OfxRectI procWindowOutput = this->translateRoWToOutputClipCoordinates( procWindowRoW ); 00050 const OfxPointI procWindowSize = { 00051 procWindowRoW.x2 - procWindowRoW.x1, 00052 procWindowRoW.y2 - procWindowRoW.y1 00053 }; 00054 00055 for( int y = procWindowOutput.y1; y < procWindowOutput.y2; ++y ) 00056 { 00057 typename ColorBarsVirtualView::x_iterator src_it = this->_srcView.x_at( procWindowOutput.x1, y ); 00058 typename View::x_iterator dst_it = this->_dstView.x_at( procWindowOutput.x1, y ); 00059 00060 for( int x = procWindowOutput.x1; x < procWindowOutput.x2; ++x, ++src_it, ++dst_it ) 00061 { 00062 *dst_it = *src_it; 00063 } 00064 if( this->progressForward( procWindowSize.x ) ) 00065 return; 00066 } 00067 } 00068 00069 } 00070 } 00071 }