TuttleOFX  1
JpegWriterPluginFactory.cpp
Go to the documentation of this file.
00001 #include "JpegWriterPluginFactory.hpp"
00002 #include "JpegWriterDefinitions.hpp"
00003 #include "JpegWriterPlugin.hpp"
00004 
00005 #include <tuttle/plugin/context/WriterPluginFactory.hpp>
00006 
00007 #include <boost/algorithm/string/join.hpp>
00008 #include <boost/assign/std/vector.hpp>
00009 
00010 #include <string>
00011 #include <vector>
00012 
00013 namespace tuttle {
00014 namespace plugin {
00015 namespace jpeg {
00016 namespace writer {
00017 
00018 /**
00019  * @brief Function called to describe the plugin main features.
00020  * @param[in, out]   desc     Effect descriptor
00021  */
00022 void JpegWriterPluginFactory::describe( OFX::ImageEffectDescriptor& desc )
00023 {
00024     desc.setLabels( "TuttleJpegWriter", "JpegWriter",
00025                     "Jpeg file writer" );
00026     desc.setPluginGrouping( "tuttle/image/io" );
00027 
00028         using namespace boost::assign;
00029         std::vector<std::string> supportedExtensions;
00030         supportedExtensions += "jpeg", "jpg", "jpe", "jfif", "jfi";
00031 
00032         desc.setDescription( "JPEG File writer\n"
00033                          "Plugin is used to write jpeg files.\n\n"
00034                          "supported extensions: \n" +
00035                          boost::algorithm::join( supportedExtensions, ", " )
00036         );
00037 
00038     // add the supported contexts
00039     desc.addSupportedContext( OFX::eContextWriter );
00040     desc.addSupportedContext( OFX::eContextGeneral );
00041 
00042     // add supported pixel depths
00043     desc.addSupportedBitDepth( OFX::eBitDepthUByte );
00044     desc.addSupportedBitDepth( OFX::eBitDepthUShort );
00045     desc.addSupportedBitDepth( OFX::eBitDepthFloat );
00046 
00047     // add supported extensions
00048         desc.addSupportedExtensions( supportedExtensions );
00049 
00050     // plugin flags
00051     desc.setRenderThreadSafety( OFX::eRenderFullySafe );
00052     desc.setHostFrameThreading( false );
00053     desc.setSupportsMultiResolution( false );
00054     desc.setSupportsMultipleClipDepths( true );
00055     desc.setSupportsTiles( kSupportTiles );
00056 }
00057 
00058 /**
00059  * @brief Function called to describe the plugin controls and features.
00060  * @param[in, out]   desc       Effect descriptor
00061  * @param[in]        context    Application context
00062  */
00063 void JpegWriterPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc,
00064                                                  OFX::EContext               context )
00065 {
00066     OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName );
00067 
00068     srcClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00069     srcClip->addSupportedComponent( OFX::ePixelComponentRGB );
00070     srcClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00071     srcClip->setSupportsTiles( kSupportTiles );
00072 
00073     OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName );
00074     dstClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00075     dstClip->addSupportedComponent( OFX::ePixelComponentRGB );
00076     dstClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00077     dstClip->setSupportsTiles( kSupportTiles );
00078 
00079         // Controls
00080         describeWriterParamsInContext( desc, context );
00081         
00082         OFX::ChoiceParamDescriptor* bitDepth = static_cast<OFX::ChoiceParamDescriptor*>( desc.getParamDescriptor( kTuttlePluginBitDepth ) );
00083         bitDepth->resetOptions();
00084         bitDepth->appendOption( kTuttlePluginBitDepth8 );
00085         bitDepth->setDefault( eTuttlePluginBitDepth8 );
00086         bitDepth->setEnabled( false );
00087 
00088         OFX::ChoiceParamDescriptor* channel = static_cast<OFX::ChoiceParamDescriptor*>( desc.getParamDescriptor( kTuttlePluginChannel ) );
00089         channel->resetOptions();
00090         channel->appendOption( kTuttlePluginChannelRGB );
00091         channel->setDefault( 0 );
00092         channel->setEnabled( false );
00093         
00094         OFX::BooleanParamDescriptor* premult = static_cast<OFX::BooleanParamDescriptor*>( desc.getParamDescriptor( kParamPremultiplied ) );
00095         premult->setDefault( true );
00096 
00097         OFX::IntParamDescriptor* quality = desc.defineIntParam( kParamQuality );
00098         quality->setLabel( "Quality" );
00099         quality->setRange( 0, 100 );
00100         quality->setDisplayRange( 0, 100 );
00101         quality->setDefault( 80 );
00102 }
00103 
00104 /**
00105  * @brief Function called to create a plugin effect instance
00106  * @param[in] handle  effect handle
00107  * @param[in] context    Application context
00108  * @return  plugin instance
00109  */
00110 OFX::ImageEffect* JpegWriterPluginFactory::createInstance( OfxImageEffectHandle handle,
00111                                                            OFX::EContext        context )
00112 {
00113     return new JpegWriterPlugin( handle );
00114 }
00115 
00116 }
00117 }
00118 }
00119 }