TuttleOFX  1
BitDepthPluginFactory.cpp
Go to the documentation of this file.
00001 #include "BitDepthPluginFactory.hpp"
00002 #include "BitDepthPlugin.hpp"
00003 #include "BitDepthDefinitions.hpp"
00004 
00005 #include <tuttle/plugin/exceptions.hpp>
00006 
00007 #include <ofxsImageEffect.h>
00008 #include <ofxsMultiThread.h>
00009 
00010 namespace tuttle {
00011 namespace plugin {
00012 namespace bitDepth {
00013 
00014 /**
00015  * @brief Function called to describe the plugin main features.
00016  * @param[in, out]   desc     Effect descriptor
00017  */
00018 void BitDepthPluginFactory::describe( OFX::ImageEffectDescriptor& desc )
00019 {
00020         desc.setLabels( "TuttleBitDepth", "BitDepth",
00021                         "Bit depth convertor" );
00022         desc.setPluginGrouping( "tuttle/image/process/color" );
00023 
00024         desc.setDescription(
00025 "Convert channels bit depth."
00026 "\n"
00027 "\n"
00028 "In computer graphics, color depth or bit depth is the number of bits used to "
00029 "represent the color of a single pixel in a bitmapped image or video frame "
00030 "buffer. This concept is also known as bits per pixel (bpp), particularly when "
00031 "specified along with the number of bits used. Higher color depth gives a "
00032 "broader range of distinct colors."
00033 "\n"
00034 "\n"
00035 "http://en.wikipedia.org/wiki/Color_depth"
00036 );
00037 
00038         // add the supported contexts
00039         desc.addSupportedContext( OFX::eContextGeneral );
00040 
00041         // add supported pixel depths
00042         desc.addSupportedBitDepth( OFX::eBitDepthUByte );
00043         desc.addSupportedBitDepth( OFX::eBitDepthUShort );
00044         desc.addSupportedBitDepth( OFX::eBitDepthFloat );
00045 
00046         // plugin flags
00047         desc.setSupportsTiles( kSupportTiles );
00048         desc.setSupportsMultipleClipDepths( true );
00049         desc.setRenderThreadSafety( OFX::eRenderFullySafe );
00050 }
00051 
00052 /**
00053  * @brief Function called to describe the plugin controls and features.
00054  * @param[in, out]   desc       Effect descriptor
00055  * @param[in]        context    Application context
00056  */
00057 void BitDepthPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc,
00058                                                OFX::EContext               context )
00059 {
00060         OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName );
00061 
00062         srcClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00063         srcClip->addSupportedComponent( OFX::ePixelComponentRGB );
00064         srcClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00065         srcClip->setSupportsTiles( kSupportTiles );
00066 
00067         // Create the mandated output clip
00068         OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName );
00069         dstClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00070         dstClip->addSupportedComponent( OFX::ePixelComponentRGB );
00071         dstClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00072         dstClip->setSupportsTiles( kSupportTiles );
00073 
00074         OFX::ChoiceParamDescriptor* outBitDepth = desc.defineChoiceParam( kParamOutputBitDepth );
00075         outBitDepth->setLabel( "Output bit depth" );
00076         outBitDepth->appendOption( "auto" );
00077         outBitDepth->appendOption( "byte (8 bits)" );
00078         outBitDepth->appendOption( "short (16 bits)" );
00079         outBitDepth->appendOption( "float (32 bits)" );
00080         outBitDepth->setDefault( 3 );
00081 }
00082 
00083 /**
00084  * @brief Function called to create a plugin effect instance
00085  * @param[in] handle  effect handle
00086  * @param[in] context    Application context
00087  * @return  plugin instance
00088  */
00089 OFX::ImageEffect* BitDepthPluginFactory::createInstance( OfxImageEffectHandle handle,
00090                                                          OFX::EContext        context )
00091 {
00092         return new BitDepthPlugin( handle );
00093 }
00094 
00095 }
00096 }
00097 }