TuttleOFX
1
|
00001 #include "ImageMagickWriterPluginFactory.hpp" 00002 #include "ImageMagickWriterDefinitions.hpp" 00003 #include "ImageMagickWriterPlugin.hpp" 00004 00005 #include <tuttle/plugin/exceptions.hpp> 00006 00007 #include <ofxsImageEffect.h> 00008 #include <ofxsMultiThread.h> 00009 00010 #include <boost/algorithm/string/join.hpp> 00011 #include <boost/assign/std/vector.hpp> 00012 00013 #include <string> 00014 #include <vector> 00015 00016 namespace tuttle { 00017 namespace plugin { 00018 namespace imagemagick { 00019 namespace writer { 00020 00021 /** 00022 * @brief Function called to describe the plugin main features. 00023 * @param[in, out] desc Effect descriptor 00024 */ 00025 void ImageMagickWriterPluginFactory::describe( OFX::ImageEffectDescriptor& desc ) 00026 { 00027 desc.setLabels( "TuttleImageMagickWriter", "ImageMagickWriter", 00028 "ImageMagick file writer" ); 00029 desc.setPluginGrouping( "tuttle/image/io" ); 00030 00031 // add the supported contexts 00032 desc.addSupportedContext( OFX::eContextWriter ); 00033 desc.addSupportedContext( OFX::eContextGeneral ); 00034 00035 // add supported pixel depths 00036 desc.addSupportedBitDepth( OFX::eBitDepthUByte ); 00037 desc.addSupportedBitDepth( OFX::eBitDepthUShort ); 00038 desc.addSupportedBitDepth( OFX::eBitDepthFloat ); 00039 00040 // add supported extensions 00041 using namespace boost::assign; 00042 std::vector<std::string> supportedExtensions; 00043 supportedExtensions += "aai", "art", "arw", "avi", "avs", "bmp", "bmp2", "bmp3", 00044 "cals", "cgm", "cin", "cmyk", "cmyka", "cr2", "crw", "cur", "cut", "dcm", 00045 "dcr", "dcx", "dib", "djvu", "dng", "dot", "dpx", "emf", "epdf", "epi", "eps", 00046 "eps2", "eps3", "epsf", "epsi", "ept", "exr", "fax", "fig", 00047 "fits", "fpx", "gif", "gplt", "gray", "hdr", "hpgl", "hrz", 00048 "html", "ico", "info", "inline", "jbig", "jng", "jp2", "jpc", 00049 "jpg", "jpeg", "man", "mat", "miff", "mono", "mng", "m2v", 00050 "mpeg", "mpc", "mpr", "mrw", "msl", "mtv", "mvg", "nef", 00051 "orf", "otb", "p7", "palm", "pam", "pbm", "pcd", "pcds", 00052 "pcl", "pcx", "pdb", "pdf", "pef", "pfa", "pfb", "pfm", 00053 "pgm", "picon", "pict", "pix", "png", "png8", "png16", "png32", 00054 "pnm", "ppm", "ps", "ps2", "ps3", "psb", "psd", "ptif", 00055 "pwp", "rad", "rgb", "rgba", "rla", "rle", "sct", "sfw", 00056 "sgi", "shtml", "sid", "mrsid", "sun", "svg", "tga", "tiff", 00057 "tim", "tif", "txt", "uil", "uyvy", "vicar", "viff", "wbmp", 00058 "webp", "wmf", "wpg", "x", "xbm", "xcf", "xpm", "xwd", "x3f", 00059 "ycbcr", "ycbcra", "yuv"; 00060 00061 desc.addSupportedExtensions( supportedExtensions ); 00062 00063 00064 // plugin flags 00065 desc.setRenderThreadSafety( OFX::eRenderFullySafe ); 00066 desc.setHostFrameThreading( false ); 00067 desc.setSupportsMultiResolution( false ); 00068 desc.setSupportsMultipleClipDepths( true ); 00069 desc.setSupportsTiles( kSupportTiles ); 00070 } 00071 00072 /** 00073 * @brief Function called to describe the plugin controls and features. 00074 * @param[in, out] desc Effect descriptor 00075 * @param[in] context Application context 00076 */ 00077 void ImageMagickWriterPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc, 00078 OFX::EContext context ) 00079 { 00080 OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName ); 00081 00082 srcClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00083 srcClip->addSupportedComponent( OFX::ePixelComponentRGB ); 00084 srcClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00085 srcClip->setSupportsTiles( kSupportTiles ); 00086 00087 OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName ); 00088 dstClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00089 dstClip->addSupportedComponent( OFX::ePixelComponentRGB ); 00090 dstClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00091 dstClip->setSupportsTiles( kSupportTiles ); 00092 00093 // Controls 00094 OFX::StringParamDescriptor* filename = desc.defineStringParam( kTuttlePluginFilename ); 00095 filename->setLabel( kTuttlePluginFilenameLabel ); 00096 filename->setStringType( OFX::eStringTypeFilePath ); 00097 filename->setCacheInvalidation( OFX::eCacheInvalidateValueAll ); 00098 desc.addClipPreferencesSlaveParam( *filename ); 00099 00100 OFX::ChoiceParamDescriptor* bitDepth = desc.defineChoiceParam( kTuttlePluginBitDepth ); 00101 bitDepth->setLabel( kTuttlePluginBitDepthLabel ); 00102 bitDepth->appendOption( kTuttlePluginBitDepth8 ); 00103 bitDepth->setCacheInvalidation( OFX::eCacheInvalidateValueAll ); 00104 bitDepth->setDefault( eTuttlePluginBitDepth8 ); 00105 00106 OFX::BooleanParamDescriptor* premult = desc.defineBooleanParam( kParamPremult ); 00107 premult->setLabel( "Premult" ); 00108 premult->setCacheInvalidation( OFX::eCacheInvalidateValueAll ); 00109 premult->setDefault( true ); 00110 00111 OFX::IntParamDescriptor* quality = desc.defineIntParam( kParamQuality ); 00112 quality->setLabel( "Quality" ); 00113 quality->setCacheInvalidation( OFX::eCacheInvalidateValueAll ); 00114 quality->setDefault( 80 ); 00115 00116 OFX::PushButtonParamDescriptor* render = desc.definePushButtonParam( kParamWriterRender ); 00117 render->setLabels( "Render", "Render", "Render step" ); 00118 render->setHint( "Force render (writing)" ); 00119 00120 OFX::BooleanParamDescriptor* renderAlways = desc.defineBooleanParam( kParamWriterRenderAlways ); 00121 renderAlways->setLabel( "Render always" ); 00122 renderAlways->setCacheInvalidation( OFX::eCacheInvalidateValueAll ); 00123 renderAlways->setDefault( false ); 00124 00125 OFX::IntParamDescriptor* forceNewRender = desc.defineIntParam( kParamWriterForceNewRender ); 00126 forceNewRender->setLabel( "Force new render" ); 00127 forceNewRender->setIsSecret( true ); 00128 forceNewRender->setIsPersistant( false ); 00129 forceNewRender->setAnimates( false ); 00130 forceNewRender->setCacheInvalidation( OFX::eCacheInvalidateValueAll ); 00131 forceNewRender->setEvaluateOnChange( true ); 00132 forceNewRender->setDefault( 0 ); 00133 } 00134 00135 /** 00136 * @brief Function called to create a plugin effect instance 00137 * @param[in] handle effect handle 00138 * @param[in] context Application context 00139 * @return plugin instance 00140 */ 00141 OFX::ImageEffect* ImageMagickWriterPluginFactory::createInstance( OfxImageEffectHandle handle, 00142 OFX::EContext context ) 00143 { 00144 return new ImageMagickWriterPlugin( handle ); 00145 } 00146 00147 } 00148 } 00149 } 00150 }