TuttleOFX
1
|
00001 #ifndef _TUTTLE_PLUGIN_IMAGEFILTERPROCESSOR_HPP_ 00002 #define _TUTTLE_PLUGIN_IMAGEFILTERPROCESSOR_HPP_ 00003 00004 #include "ImageProcessor.hpp" 00005 00006 namespace tuttle { 00007 namespace plugin { 00008 00009 /** 00010 * @brief Base class that can be used to process images of any type using boost::gil library view to access images. 00011 */ 00012 class ImageFilterProcessor : public ImageProcessor 00013 { 00014 protected: 00015 OFX::Clip* _clipSrc; ///< Source image clip 00016 boost::scoped_ptr<OFX::Image> _src; 00017 OfxRectI _srcPixelRod; 00018 00019 public: 00020 ImageFilterProcessor( OFX::ImageEffect& effect, const EImageOrientation imageOrientation ) 00021 : ImageProcessor( effect, imageOrientation ) 00022 { 00023 _clipSrc = effect.fetchClip( kOfxImageEffectSimpleSourceClipName ); 00024 00025 if( ! _clipSrc->isConnected() ) 00026 BOOST_THROW_EXCEPTION( exception::ImageNotConnected() ); 00027 } 00028 00029 virtual ~ImageFilterProcessor() 00030 {} 00031 00032 virtual void setup( const OFX::RenderArguments& args ) 00033 { 00034 ImageProcessor::setup( args ); 00035 00036 // source view 00037 _src.reset( _clipSrc->fetchImage( args.time ) ); 00038 if( ! _src.get() ) 00039 BOOST_THROW_EXCEPTION( exception::ImageNotReady() 00040 << exception::dev() + "Error on clip " + quotes(_clipSrc->name()) ); 00041 if( _src->getRowDistanceBytes() == 0 ) 00042 BOOST_THROW_EXCEPTION( exception::WrongRowBytes() 00043 << exception::dev() + "Error on clip " + quotes(_clipSrc->name()) ); 00044 00045 if( OFX::getImageEffectHostDescription()->hostName == "uk.co.thefoundry.nuke" ) 00046 { 00047 // bug in nuke, getRegionOfDefinition() on OFX::Image returns bounds 00048 _srcPixelRod = _clipSrc->getPixelRod( args.time, args.renderScale ); 00049 } 00050 else 00051 { 00052 _srcPixelRod = _src->getRegionOfDefinition(); 00053 } 00054 } 00055 }; 00056 00057 00058 } 00059 } 00060 00061 #endif 00062