TuttleOFX  1
OpenImageIOWriterPluginFactory.cpp
Go to the documentation of this file.
00001 #include "OpenImageIOWriterPluginFactory.hpp"
00002 #include "OpenImageIOWriterPluginFactory.hpp"
00003 #include "OpenImageIOWriterDefinitions.hpp"
00004 #include "OpenImageIOWriterPlugin.hpp"
00005 
00006 #include <tuttle/plugin/context/WriterPluginFactory.hpp>
00007 
00008 #include <boost/algorithm/string/join.hpp>
00009 #include <boost/assign/std/vector.hpp>
00010 
00011 #include <string>
00012 #include <vector>
00013 
00014 namespace tuttle {
00015 namespace plugin {
00016 namespace openImageIO {
00017 namespace writer {
00018 
00019 /**
00020  * @brief Function called to describe the plugin main features.
00021  * @param[in, out]   desc     Effect descriptor
00022  */
00023 void OpenImageIOWriterPluginFactory::describe( OFX::ImageEffectDescriptor& desc )
00024 {
00025         desc.setLabels( "TuttleOpenImageIOWriter", "OpenImageIOWriter",
00026                                         "OpenImageIO file writer" );
00027         desc.setPluginGrouping( "tuttle/image/io" );
00028         
00029         using namespace boost::assign;
00030         std::vector<std::string> supportedExtensions;
00031         supportedExtensions += "bmp", "cin", "dds", "dpx", "exr", "fits", "hdr", "ico", 
00032                         "j2k", "j2c", "jp2", "jpeg", "jpg", "jpe", "jfif", "jfi", 
00033                         "pbm", "pgm", "png", "pnm", "ppm", "pic",
00034                         //"psd",
00035                         "rgbe", "sgi", "tga", "tif", "tiff", "tpic",
00036                         //"tx",
00037                         "webp";
00038         
00039         desc.setDescription(
00040                                 "OpenImageIO Writer"
00041                                 "\n\n"
00042                                 "supported extensions: \n" +
00043                                 boost::algorithm::join( supportedExtensions, ", " )
00044                                 );
00045         
00046         // add the supported contexts
00047         desc.addSupportedContext( OFX::eContextWriter );
00048         desc.addSupportedContext( OFX::eContextGeneral );
00049         
00050         // add supported pixel depths
00051         desc.addSupportedBitDepth( OFX::eBitDepthUByte );
00052         desc.addSupportedBitDepth( OFX::eBitDepthUShort );
00053         desc.addSupportedBitDepth( OFX::eBitDepthFloat );
00054         
00055         // add supported extensions
00056         desc.addSupportedExtensions( supportedExtensions );
00057         
00058         // plugin flags
00059         desc.setRenderThreadSafety( OFX::eRenderFullySafe );
00060         desc.setHostFrameThreading         ( false );
00061         desc.setSupportsMultiResolution    ( false );
00062         desc.setSupportsMultipleClipDepths ( true );
00063         desc.setSupportsTiles              ( kSupportTiles );
00064 }
00065 
00066 /**
00067  * @brief Function called to describe the plugin controls and features.
00068  * @param[in, out]   desc       Effect descriptor
00069  * @param[in]        context    Application context
00070  */
00071 void OpenImageIOWriterPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc,
00072                                                                                                                 OFX::EContext               context )
00073 {
00074         OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName );
00075         srcClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00076         srcClip->addSupportedComponent( OFX::ePixelComponentRGB );
00077         srcClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00078         srcClip->setSupportsTiles( kSupportTiles );
00079         
00080         OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName );
00081         dstClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00082         dstClip->addSupportedComponent( OFX::ePixelComponentRGB );
00083         dstClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00084         dstClip->setSupportsTiles( kSupportTiles );
00085         
00086         // Controls
00087         describeWriterParamsInContext( desc, context );
00088         
00089         OFX::ChoiceParamDescriptor* bitDepth = static_cast<OFX::ChoiceParamDescriptor*>( desc.getParamDescriptor( kTuttlePluginBitDepth ) );
00090         bitDepth->resetOptions();
00091         bitDepth->appendOption( kTuttlePluginBitDepthAuto );
00092         bitDepth->appendOption( kTuttlePluginBitDepth8 );
00093         bitDepth->appendOption( kTuttlePluginBitDepth10 );
00094         bitDepth->appendOption( kTuttlePluginBitDepth12 );
00095         bitDepth->appendOption( kTuttlePluginBitDepth16 );
00096         bitDepth->appendOption( kTuttlePluginBitDepth16f );
00097         bitDepth->appendOption( kTuttlePluginBitDepth32 );
00098         bitDepth->appendOption( kTuttlePluginBitDepth32f );
00099         bitDepth->setDefault( eTuttlePluginBitDepthAuto );
00100         
00101         OFX::IntParamDescriptor* quality = desc.defineIntParam( kParamOutputQuality );
00102         quality->setLabel( kParamOutputQualityLabel );
00103         quality->setRange( 0, 100 );
00104         quality->setDisplayRange( 0, 100 );
00105         quality->setDefault( 80 );
00106         
00107         OFX::ChoiceParamDescriptor* orientation = desc.defineChoiceParam( kParamOutputOrientation );
00108         orientation->setLabel( kParamOutputOrientationLabel );
00109         orientation->appendOption( kParamOutputOrientationNormal );
00110         orientation->appendOption( kParamOutputOrientationFlop );
00111         orientation->appendOption( kParamOutputOrientationR180 );
00112         orientation->appendOption( kParamOutputOrientationFlip );
00113         orientation->appendOption( kParamOutputOrientationTransposed );
00114         orientation->appendOption( kParamOutputOrientationR90Clockwise );
00115         orientation->appendOption( kParamOutputOrientationTransverse );
00116         orientation->appendOption( kParamOutputOrientationR90CounterClockwise );
00117         orientation->setDefault( 0 );
00118         
00119         OFX::ChoiceParamDescriptor* compression = desc.defineChoiceParam( kParamOutputCompression );
00120         compression->setLabel( kParamOutputOrientationLabel );
00121 #ifndef TUTTLE_PRODUCTION
00122         compression->appendOption( kParamOutputCompressionNone );
00123 #endif
00124         compression->appendOption( kParamOutputCompressionZip );
00125 #ifndef TUTTLE_PRODUCTION
00126         compression->appendOption( kParamOutputCompressionZips );
00127         compression->appendOption( kParamOutputCompressionRle );
00128         compression->appendOption( kParamOutputCompressionPiz );
00129         compression->appendOption( kParamOutputCompressionPxr24 );
00130         compression->appendOption( kParamOutputCompressionB44 );
00131         compression->appendOption( kParamOutputCompressionB44a );
00132         compression->setDefault( eParamCompressionNone );
00133 #else
00134         compression->setDefault( 0 );
00135 #endif
00136 }
00137 
00138 /**
00139  * @brief Function called to create a plugin effect instance
00140  * @param[in] handle  effect handle
00141  * @param[in] context    Application context
00142  * @return  plugin instance
00143  */
00144 OFX::ImageEffect* OpenImageIOWriterPluginFactory::createInstance( OfxImageEffectHandle handle,
00145                                                                                                                                   OFX::EContext        context )
00146 {
00147         return new OpenImageIOWriterPlugin( handle );
00148 }
00149 
00150 }
00151 }
00152 }
00153 }