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 #ifndef TUTTLE_PRODUCTION 00037 // init dst buffer with red to highlight uninitialized pixels 00038 const OfxRectI dstBounds = this->translateRoWToOutputClipCoordinates( _dst->getBounds() ); 00039 View dstToFill = boost::gil::subimage_view( _dstView, 00040 dstBounds.x1, dstBounds.y1, 00041 dstBounds.x2 - dstBounds.x1, dstBounds.y2 - dstBounds.y1 ); 00042 const boost::gil::rgba32f_pixel_t errorColor( 1.0, 0.0, 0.0, 1.0 ); 00043 fill_pixels( dstToFill, errorColor ); 00044 #endif 00045 } 00046 00047 /** 00048 * @brief Return a full gil view of an image. 00049 */ 00050 View getView( OFX::Image* img, const OfxRectI& pixelRod ) const 00051 { 00052 return tuttle::plugin::getGilView<View>( img, pixelRod, _imageOrientation ); 00053 } 00054 template<typename CustomView> 00055 CustomView getCustomView( OFX::Image* img, const OfxRectI& pixelRod ) const 00056 { 00057 return tuttle::plugin::getGilView<CustomView>( img, pixelRod, _imageOrientation ); 00058 } 00059 }; 00060 00061 } 00062 } 00063 00064 #endif 00065