TuttleOFX  1
ImageMagickWriterPlugin.cpp
Go to the documentation of this file.
00001 #include "ImageMagickWriterDefinitions.hpp"
00002 #include "ImageMagickWriterPlugin.hpp"
00003 #include "ImageMagickWriterProcess.hpp"
00004 
00005 #include <boost/gil/gil_all.hpp>
00006 
00007 namespace tuttle {
00008 namespace plugin {
00009 namespace imagemagick {
00010 namespace writer {
00011 
00012 ImageMagickWriterPlugin::ImageMagickWriterPlugin( OfxImageEffectHandle handle )
00013         : WriterPlugin( handle )
00014 {
00015         _premult = fetchBooleanParam( kParamPremult );
00016         _quality = fetchIntParam( kParamQuality );
00017 }
00018 
00019 ImageMagickWriterProcessParams ImageMagickWriterPlugin::getProcessParams( const OfxTime time )
00020 {
00021         ImageMagickWriterProcessParams params;
00022 
00023         params._filepath = getAbsoluteFilenameAt( time );
00024         params._quality  = this->_quality->getValue();
00025         params._premult  = this->_premult->getValue();
00026         return params;
00027 }
00028 
00029 /**
00030  * @brief The overridden render function
00031  * @param[in]   args     Rendering parameters
00032  */
00033 void ImageMagickWriterPlugin::render( const OFX::RenderArguments& args )
00034 {
00035         WriterPlugin::render( args );
00036         
00037         // instantiate the render code based on the pixel depth of the dst clip
00038         OFX::EBitDepth bitDepth         = _clipSrc->getPixelDepth();
00039         OFX::EPixelComponent components = _clipSrc->getPixelComponents();
00040 
00041         switch( components )
00042         {
00043                 case OFX::ePixelComponentRGBA:
00044                 {
00045                         doGilRender<ImageMagickWriterProcess, false, boost::gil::rgba_layout_t>( *this, args, bitDepth );
00046                         return;
00047                 }
00048                 case OFX::ePixelComponentRGB:
00049                 case OFX::ePixelComponentAlpha:
00050                 case OFX::ePixelComponentCustom:
00051                 case OFX::ePixelComponentNone:
00052                 {
00053                         BOOST_THROW_EXCEPTION( exception::Unsupported()
00054                                 << exception::user() + "Pixel components (" + mapPixelComponentEnumToString(components) + ") not supported by the plugin." );
00055                 }
00056         }
00057         BOOST_THROW_EXCEPTION( exception::Unknown() );
00058 }
00059 
00060 }
00061 }
00062 }
00063 }