TuttleOFX
1
|
00001 #include "FlipPlugin.hpp" 00002 00003 #include <boost/gil/image_view_factory.hpp> 00004 #include <boost/gil/gil_all.hpp> 00005 00006 namespace tuttle { 00007 namespace plugin { 00008 namespace flip { 00009 00010 template<class View> 00011 FlipProcess<View>::FlipProcess( FlipPlugin& instance ) 00012 : ImageGilFilterProcessor<View>( instance, eImageOrientationIndependant ) 00013 , _plugin( instance ) { } 00014 00015 template<class View> 00016 void FlipProcess<View>::setup( const OFX::RenderArguments& args ) 00017 { 00018 ImageGilFilterProcessor<View>::setup( args ); 00019 00020 _params = _plugin.getProcessParams( args.time, args.renderScale ); 00021 } 00022 00023 /** 00024 * @brief Function called by rendering thread each time a process must be done. 00025 * @param[in] procWindowRoW Processing window in RoW 00026 */ 00027 template<class View> 00028 void FlipProcess<View>::multiThreadProcessImages( const OfxRectI& procWindowRoW ) 00029 { 00030 using namespace boost::gil; 00031 00032 OfxRectI procWindowOutput = this->translateRoWToOutputClipCoordinates( procWindowRoW ); 00033 OfxPointI procWindowSize = { 00034 procWindowRoW.x2 - procWindowRoW.x1, 00035 procWindowRoW.y2 - procWindowRoW.y1 00036 }; 00037 00038 View src; 00039 View dst = subimage_view( 00040 this->_dstView, 00041 procWindowOutput.x1, procWindowOutput.y1, 00042 procWindowSize.x, procWindowSize.y ); 00043 00044 if( _params.flip ) 00045 { 00046 /// @todo Need an option to choose the center and modify the ouput RoD. 00047 /// Here (inputRoD == outputRod), so we use the center of the inputRoD. 00048 src = subimage_view( 00049 this->_srcView, 00050 this->_dstPixelRod.x2 - procWindowOutput.x2 + this->_dstPixelRod.x1, 00051 this->_dstPixelRod.y2 - procWindowOutput.y2 - this->_dstPixelRod.y1, 00052 procWindowSize.x, procWindowSize.y ); 00053 00054 // flip_up_down_view don't modify the View type 00055 src = flipped_up_down_view( src ); 00056 } 00057 else 00058 { 00059 src = subimage_view( 00060 this->_srcView, 00061 procWindowOutput.x1, procWindowOutput.y1, 00062 procWindowSize.x, procWindowSize.y ); 00063 } 00064 00065 if( _params.flop ) 00066 { 00067 /// @todo Need to do the same thing than for flip. 00068 /// this->_dstPixelRod.x1 could be different from 0. 00069 00070 // flip_left_right_view modify the View type 00071 copy_pixels( boost::gil::flipped_left_right_view( src ), dst ); 00072 } 00073 else 00074 { 00075 copy_pixels( src, dst ); 00076 } 00077 } 00078 00079 } 00080 } 00081 }