TuttleOFX
1
|
00001 #ifndef _TUTTLE_PLUGIN_IMAGEGILPROCESSOR_HPP_ 00002 #define _TUTTLE_PLUGIN_IMAGEGILPROCESSOR_HPP_ 00003 00004 #include "ImageProcessor.hpp" 00005 00006 #include <terry/globals.hpp> 00007 #include <tuttle/plugin/ofxToGil/image.hpp> 00008 00009 namespace tuttle { 00010 namespace plugin { 00011 00012 /** 00013 * @brief Base class that can be used to process images of any type using boost::gil library view to access images. 00014 */ 00015 template <class View> 00016 class ImageGilProcessor : public ImageProcessor 00017 { 00018 public: 00019 typedef typename View::value_type Pixel; 00020 typedef typename terry::image_from_view<View>::type Image; 00021 00022 protected: 00023 View _dstView; ///< image to process into 00024 00025 public: 00026 ImageGilProcessor( OFX::ImageEffect& effect, const EImageOrientation imageOrientation ) 00027 : ImageProcessor( effect, imageOrientation ) 00028 {} 00029 virtual ~ImageGilProcessor() {} 00030 00031 virtual void setup( const OFX::RenderArguments& args ) 00032 { 00033 ImageProcessor::setup( args ); 00034 _dstView = getView( _dst.get(), _dstPixelRod ); 00035 00036 #if(TUTTLE_INIT_IMAGE_BUFFERS) 00037 const OfxRectI dstRenderWin = this->translateRoWToOutputClipCoordinates( args.renderWindow ); 00038 View dstToFill = boost::gil::subimage_view( _dstView, 00039 dstRenderWin.x1, dstRenderWin.y1, 00040 dstRenderWin.x2 - dstRenderWin.x1, dstRenderWin.y2 - dstRenderWin.y1 ); 00041 const boost::gil::rgba32f_pixel_t errorColor( 1.0, 0.0, 0.0, 1.0 ); 00042 fill_pixels( dstToFill, errorColor ); 00043 #endif 00044 } 00045 00046 /** 00047 * @brief Return a full gil view of an image. 00048 */ 00049 View getView( OFX::Image* img, const OfxRectI& pixelRod ) const 00050 { 00051 return tuttle::plugin::getGilView<View>( img, pixelRod, _imageOrientation ); 00052 } 00053 template<typename CustomView> 00054 CustomView getCustomView( OFX::Image* img, const OfxRectI& pixelRod ) const 00055 { 00056 return tuttle::plugin::getGilView<CustomView>( img, pixelRod, _imageOrientation ); 00057 } 00058 }; 00059 00060 } 00061 } 00062 00063 #endif 00064