TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/common/ofx/imageEffect.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_COMMON_OFX_IMAGEEFFECT_HPP_
00002 #define _TUTTLE_COMMON_OFX_IMAGEEFFECT_HPP_
00003 
00004 #include <tuttle/common/exceptions.hpp>
00005 
00006 #include <boost/cstdint.hpp>
00007 
00008 #include <string>
00009 
00010 namespace tuttle {
00011 namespace ofx {
00012 namespace imageEffect {
00013 
00014 /** @brief Enumerates the contexts a plugin can be used in */
00015 enum EContext
00016 {
00017         eContextNone,
00018         eContextGenerator,
00019         eContextFilter,
00020         eContextTransition,
00021         eContextPaint,
00022         eContextGeneral,
00023         eContextRetimer,
00024         eContextReader,
00025         eContextWriter
00026 };
00027 
00028 const std::string mapContextEnumToString( const EContext s );
00029 
00030 /** @brief Enumerates the pixel depths supported */
00031 enum EBitDepth
00032 {
00033         eBitDepthNone   = -1, ///< @brief bit depth that indicates no data is present
00034         eBitDepthCustom = 0, ///< some non standard bit depth
00035         eBitDepthUByte  = 1,
00036         eBitDepthUShort = 2,
00037         eBitDepthFloat  = 4
00038 };
00039 
00040 const std::string mapBitDepthEnumToString( const EBitDepth e );
00041 EBitDepth         mapBitDepthStringToEnum( const std::string& str );
00042 
00043 inline std::size_t bitDepthMemorySize( const EBitDepth e )
00044 {
00045         switch( e )
00046         {
00047                 case eBitDepthUByte:
00048                         return sizeof( boost::uint8_t );
00049                 case eBitDepthUShort:
00050                         return sizeof( boost::uint16_t );
00051                 case eBitDepthFloat:
00052                         return sizeof( float );
00053                 case eBitDepthNone:
00054                 case eBitDepthCustom:
00055                         return 0;
00056         }
00057         BOOST_ASSERT( false );
00058         return 0;
00059 }
00060 
00061 /** @brief Enumerates the component types supported */
00062 enum EPixelComponent
00063 {
00064         ePixelComponentNone,
00065         ePixelComponentRGBA,
00066         ePixelComponentRGB,
00067         ePixelComponentAlpha,
00068         ePixelComponentCustom ///< some non standard pixel type
00069 };
00070 
00071 std::string     mapPixelComponentEnumToString( const EPixelComponent e );
00072 EPixelComponent mapPixelComponentStringToEnum( const std::string& str );
00073 
00074 inline std::size_t numberOfComponents( const EPixelComponent c )
00075 {
00076         switch( c )
00077         {
00078                 case ePixelComponentRGBA:
00079                         return 4;
00080                 case ePixelComponentRGB:
00081                         return 3;
00082                 case ePixelComponentAlpha:
00083                         return 1;
00084                 case ePixelComponentNone:
00085                         return 0;
00086                 case ePixelComponentCustom:
00087                         BOOST_THROW_EXCEPTION( exception::Value()
00088                             << exception::user() + "Can't retrieve the number of values inside a custom pixel component." );
00089         }
00090         BOOST_ASSERT( false );
00091         return 0;
00092 }
00093 
00094 /// get me deepest bit depth
00095 std::string findDeepestBitDepth( const std::string& s1, const std::string& s2 );
00096 
00097 }
00098 }
00099 }
00100 
00101 #endif
00102