TuttleOFX  1
ColorTransformPlugin.cpp
Go to the documentation of this file.
00001 #include "ColorTransformPlugin.hpp"
00002 #include "ColorTransformProcess.hpp"
00003 #include "ColorTransformAlgorithm.hpp"
00004 #include "ColorTransformDefinitions.hpp"
00005 
00006 #include <boost/gil/gil_all.hpp>
00007 #include <boost/numeric/ublas/traits.hpp>
00008 
00009 namespace tuttle {
00010 namespace plugin {
00011 namespace colorTransform {
00012 
00013 
00014 ColorTransformPlugin::ColorTransformPlugin( OfxImageEffectHandle handle )
00015 : ImageEffectGilPlugin( handle )
00016 {
00017         _paramHueShift = fetchDoubleParam( kParamHueShift );
00018         _paramSaturation = fetchDoubleParam( kParamSaturation );
00019         
00020         _paramContrastRGB = fetchDoubleParam( kParamContrastRGB );
00021         _paramContrast = fetchRGBAParam( kParamContrast );
00022         _paramBrightnessRGB = fetchDoubleParam( kParamBrightnessRGB );
00023         _paramBrightness = fetchRGBAParam( kParamBrightness );
00024         _paramOffsetRGB = fetchDoubleParam( kParamOffsetRGB );
00025         _paramOffset = fetchRGBAParam( kParamOffset );
00026         _paramPivotRGB = fetchDoubleParam( kParamPivotRGB );
00027         _paramPivot = fetchRGBAParam( kParamPivot );
00028 }
00029 
00030 ColorTransformParams ColorTransformPlugin::getProcessParams( const OfxPointD& renderScale ) const
00031 {
00032         ColorTransformParams params;
00033         
00034         params._hueShift = _paramHueShift->getValue();
00035         params._saturation = _paramSaturation->getValue();
00036         
00037         params._contrastRGB = _paramContrastRGB->getValue();
00038         params._contrast = _paramContrast->getValue();
00039         params._brightnessRGB = _paramBrightnessRGB->getValue();
00040         params._brightness = _paramBrightness->getValue();
00041         params._offsetRGB = _paramOffsetRGB->getValue();
00042         params._offset = _paramOffset->getValue();
00043         params._pivotRGB = _paramPivotRGB->getValue();
00044         params._pivot = _paramPivot->getValue();
00045         
00046         return params;
00047 }
00048 
00049 void ColorTransformPlugin::changedParam( const OFX::InstanceChangedArgs &args, const std::string &paramName )
00050 {
00051 //    if( paramName == kParamHelpButton )
00052 //    {
00053 //        sendMessage( OFX::Message::eMessageMessage,
00054 //                     "", // No XML resources
00055 //                     kParamHelpString );
00056 //    }
00057 }
00058 
00059 bool ColorTransformPlugin::isIdentity( const OFX::RenderArguments& args, OFX::Clip*& identityClip, double& identityTime )
00060 {
00061         using namespace boost::numeric::ublas; 
00062         ColorTransformParams params = getProcessParams();
00063         
00064         typedef terry::math::BoundedMatrix<Scalar, 5, 5>::Type BoundedMatrix5x5;
00065         BoundedMatrix5x5 matrix = colorTransformMatrix<BoundedMatrix5x5>( params );
00066         
00067 //      if( equals( matrix, identity_matrix<Scalar>(5) ) )
00068 //      {
00069 //              identityClip = _clipSrc;
00070 //              identityTime = args.time;
00071 //              return true;
00072 //      }
00073         return false;
00074 }
00075 
00076 /**
00077  * @brief The overridden render function
00078  * @param[in]   args     Rendering parameters
00079  */
00080 void ColorTransformPlugin::render( const OFX::RenderArguments &args )
00081 {
00082         doGilRender<ColorTransformProcess>( *this, args );
00083 /*
00084         // instantiate the render code based on the pixel depth of the dst clip
00085         OFX::EBitDepth bitDepth         = _clipDst->getPixelDepth();
00086         OFX::EPixelComponent components = _clipDst->getPixelComponents();
00087 
00088         switch( components )
00089         {
00090                 case OFX::ePixelComponentRGBA:
00091                 {
00092                         doGilRender<ColorTransformProcess, false, boost::gil::rgba_layout_t>( *this, args, bitDepth );
00093                         return;
00094                 }
00095                 case OFX::ePixelComponentRGB:
00096                 {
00097                         doGilRender<ColorTransformProcess, false, boost::gil::rgb_layout_t>( *this, args, bitDepth );
00098                         return;
00099                 }
00100                 case OFX::ePixelComponentAlpha:
00101                 case OFX::ePixelComponentCustom:
00102                 case OFX::ePixelComponentNone:
00103                 {
00104                         BOOST_THROW_EXCEPTION( exception::Unsupported()
00105                                 << exception::user() + "Pixel components (" + mapPixelComponentEnumToString(components) + ") not supported by the plugin." );
00106                 }
00107         }
00108         BOOST_THROW_EXCEPTION( exception::Unknown() );
00109 */
00110 }
00111 
00112 }
00113 }
00114 }