TuttleOFX
1
|
00001 #include "InvertPlugin.hpp" 00002 #include "InvertProcess.hpp" 00003 00004 #include <boost/gil/gil_all.hpp> 00005 00006 namespace tuttle { 00007 namespace plugin { 00008 namespace invert { 00009 00010 using namespace boost::gil; 00011 00012 InvertPlugin::InvertPlugin( OfxImageEffectHandle handle ) 00013 : ImageEffectGilPlugin( handle ) 00014 { 00015 _paramProcessGroup = fetchGroupParam( kParamProcessGroup ); 00016 _paramProcessR = fetchBooleanParam( kParamProcessR ); 00017 _paramProcessG = fetchBooleanParam( kParamProcessG ); 00018 _paramProcessB = fetchBooleanParam( kParamProcessB ); 00019 _paramProcessA = fetchBooleanParam( kParamProcessA ); 00020 _paramProcessGray = fetchBooleanParam( kParamProcessGray ); 00021 } 00022 00023 InvertProcessParams InvertPlugin::getProcessParams( const OfxPointD& renderScale ) const 00024 { 00025 InvertProcessParams params; 00026 00027 params._red = _paramProcessR->getValue(); 00028 params._green = _paramProcessG->getValue(); 00029 params._blue = _paramProcessB->getValue(); 00030 params._alpha = _paramProcessA->getValue(); 00031 params._gray = _paramProcessGray->getValue(); 00032 00033 return params; 00034 } 00035 00036 /** 00037 * @brief The overridden render function 00038 * @param[in] args Rendering parameters 00039 */ 00040 void InvertPlugin::render( const OFX::RenderArguments& args ) 00041 { 00042 // instantiate the render code based on the pixel depth of the dst clip 00043 const OFX::EBitDepth bitDepth = _clipDst->getPixelDepth(); 00044 const OFX::EPixelComponent components = _clipDst->getPixelComponents(); 00045 00046 switch( components ) 00047 { 00048 case OFX::ePixelComponentRGBA: 00049 { 00050 doGilRender<InvertProcess, false, boost::gil::rgba_layout_t>( *this, args, bitDepth ); 00051 return; 00052 } 00053 case OFX::ePixelComponentRGB: 00054 { 00055 doGilRender<InvertProcess, false, boost::gil::rgb_layout_t>( *this, args, bitDepth ); 00056 return; 00057 } 00058 case OFX::ePixelComponentAlpha: 00059 { 00060 doGilRender<InvertProcess, false, boost::gil::gray_layout_t>( *this, args, bitDepth ); 00061 return; 00062 } 00063 case OFX::ePixelComponentCustom: 00064 case OFX::ePixelComponentNone: 00065 { 00066 BOOST_THROW_EXCEPTION( exception::Unsupported() 00067 << exception::user() + "Pixel components (" + mapPixelComponentEnumToString(components) + ") not supported by the plugin." ); 00068 } 00069 } 00070 BOOST_THROW_EXCEPTION( exception::Unknown() ); 00071 } 00072 00073 } 00074 } 00075 }