TuttleOFX  1
EXRReaderProcess.hpp
Go to the documentation of this file.
00001 #ifndef _EXR_READER_PROCESS_HPP_
00002 #define _EXR_READER_PROCESS_HPP_
00003 
00004 #include <tuttle/plugin/global.hpp>
00005 #include <tuttle/plugin/ImageGilProcessor.hpp>
00006 #include <tuttle/plugin/memory/OfxAllocator.hpp>
00007 
00008 #include <ofxsImageEffect.h>
00009 #include <ofxsMultiThread.h>
00010 
00011 #include <ImfInputFile.h>
00012 
00013 #include <boost/scoped_ptr.hpp>
00014 
00015 namespace tuttle {
00016 namespace plugin {
00017 namespace exr    {
00018 namespace reader {
00019 
00020 /**
00021  * @brief Exr reader
00022  */
00023 template<class View>
00024 class EXRReaderProcess : public ImageGilProcessor<View>
00025 {
00026 protected:
00027         typedef typename View::value_type              Pixel;
00028         typedef std::vector<char, OfxAllocator<char> > DataVector;
00029         
00030         EXRReaderPlugin&                    _plugin;    ///< Rendering plugin
00031         EXRReaderProcessParams              _params;
00032         boost::scoped_ptr<Imf::InputFile>   _exrImage;  ///< Pointer to an exr image
00033 
00034         template< typename PixelType >
00035         void initExrChannel( DataVector& data, Imf::Slice& slice, Imf::FrameBuffer& frameBuffer, Imf::PixelType pixelType, std::string channelID, const Imath::Box2i& dw, int w, int h );
00036         
00037         template<class DView>
00038         void channelCopy( Imf::InputFile& input, Imf::FrameBuffer& frameBuffer, const EXRReaderProcessParams& params,
00039                                           DView& dst, int w, int h, size_t nc );
00040         
00041         template<class DView, typename workingView>
00042         void sliceCopy( Imf::InputFile& input, const Imf::Slice* slice, DView& dst, const EXRReaderProcessParams& params, int w, int h, int n );
00043 
00044         std::string getChannelName( size_t index );
00045         
00046 public:
00047         EXRReaderProcess<View>( EXRReaderPlugin & instance );
00048 
00049         void setup( const OFX::RenderArguments& args );
00050 
00051         void multiThreadProcessImages( const OfxRectI& procWindowRoW );
00052 
00053         // Read exr image
00054         template<class DView>
00055         void readImage( DView dst, const std::string& filepath );
00056 };
00057 
00058 }
00059 }
00060 }
00061 }
00062 
00063 #include "EXRReaderProcess.tcc"
00064 
00065 #endif