Thread: [Hdrflow-svn] SF.net SVN: hdrflow: [280] trunk/lib/extras/src/imf/mfn
Status: Pre-Alpha
Brought to you by:
glslang
From: <gl...@us...> - 2007-08-27 15:50:15
|
Revision: 280 http://hdrflow.svn.sourceforge.net/hdrflow/?rev=280&view=rev Author: glslang Date: 2007-08-26 07:36:26 -0700 (Sun, 26 Aug 2007) Log Message: ----------- + maya 8.5 HDR plugin functional. needs testing Modified Paths: -------------- trunk/lib/extras/src/imf/mfn/Makefile.am trunk/lib/extras/src/imf/mfn/mfn.cpp Modified: trunk/lib/extras/src/imf/mfn/Makefile.am =================================================================== --- trunk/lib/extras/src/imf/mfn/Makefile.am 2007-08-26 14:14:16 UTC (rev 279) +++ trunk/lib/extras/src/imf/mfn/Makefile.am 2007-08-26 14:36:26 UTC (rev 280) @@ -19,7 +19,8 @@ libhdrflow_extras_mfn_la_LIBADD = \ $(MAYA_LIBS) \ - $(top_builddir)/../openlibraries/src/openpluginlib/pl/libopenpluginlib_pl.la + $(top_builddir)/../openlibraries/src/openpluginlib/pl/libopenpluginlib_pl.la \ + $(top_builddir)/../openlibraries/src/openimagelib/il/libopenimagelib_il.la libhdrflow_extras_mfn_la_LDFLAGS = \ $(MAYA_LDFLAGS) Modified: trunk/lib/extras/src/imf/mfn/mfn.cpp =================================================================== --- trunk/lib/extras/src/imf/mfn/mfn.cpp 2007-08-26 14:14:16 UTC (rev 279) +++ trunk/lib/extras/src/imf/mfn/mfn.cpp 2007-08-26 14:36:26 UTC (rev 280) @@ -5,6 +5,10 @@ // Released under the GPL. // For more information, see http://www.cryogenicgraphics.com/hdrflow. +#ifdef __APPLE__ +#include <maya/OpenMayaMac.h> +#endif + #include <maya/MPxImageFile.h> #include <maya/MImageFileInfo.h> #include <maya/MImage.h> @@ -13,3 +17,189 @@ #include <maya/MIOStream.h> #include <maya/MGlobal.h> +#include <openpluginlib/pl/openpluginlib.hpp> +#include <openpluginlib/pl/utf8_utils.hpp> +#include <openpluginlib/pl/stream.hpp> + +#include <openimagelib/il/openimagelib_plugin.hpp> + +namespace pl = olib::openpluginlib; +namespace il = olib::openimagelib::il; + +namespace hdrflow { namespace extras { namespace mfn { + +namespace +{ + struct query_traits + { + query_traits( const pl::wstring& filename ) + : filename_( filename ) + { } + + pl::wstring libname( ) const + { return L"openimagelib"; } + + pl::wstring to_match( ) const + { return filename_; } + + pl::wstring type( ) const + { return L""; } + + int merit( ) const + { return 0; } + + pl::wstring filename_; + }; +} + +class image_reader : public MPxImageFile +{ +public: + explicit image_reader( ); + virtual ~image_reader( ); + + static void* creator( ); + + virtual MStatus open( MString pathname, MImageFileInfo* info ); + virtual MStatus load( MImage& image, unsigned int idx ); + virtual MStatus close( ); + +private: + il::image_type_ptr im_; +}; + +image_reader::image_reader( ) +{ } + +image_reader::~image_reader( ) +{ } + +void* image_reader::creator( ) +{ + return new image_reader; +} + +MStatus image_reader::open( MString pathname, MImageFileInfo* info ) +{ +#ifndef NDEBUG + MGlobal::displayInfo( "HDRFlow: opening image..." ); +#endif + + typedef pl::discovery<query_traits> discovery; + + discovery plugins( query_traits( pl::to_wstring( pathname.asChar( ) ) ) ); + if( plugins.empty( ) ) return MS::kFailure; + + for( discovery::const_iterator i = plugins.begin( ); i != plugins.end( ); ++i ) + { + il::openimagelib_plugin_ptr plug = boost::shared_dynamic_cast<il::openimagelib_plugin>( i->create_plugin( "" ) ); + if( plug ) + { +#ifndef NDEBUG + MGlobal::displayInfo( "HDRFlow: plugin found ..." ); +#endif + im_ = il::conform( plug->load( pl::make_stream( pathname.asChar( ), std::ios::in ) ), il::flipped ); + if( im_ ) + { +#ifndef NDEBUG + MGlobal::displayInfo( "HDRFlow: image opened." ); +#endif + if( info ) + { + info->width( im_->width( ) ); + info->height( im_->height( ) ); + info->channels( 4 ); // always assumes alpha/matte exists + info->numberOfImages( 1 ); + info->pixelType( MImage::kFloat ); // convert everything to float by default + } + + return MS::kSuccess; + } +#ifndef NDEBUG + else + { + MGlobal::displayInfo( "HDRFlow: image is null." ); + } +#endif + } +#ifndef NDEBUG + else + { + MGlobal::displayInfo( "HDRFlow: plugin is null." ); + } +#endif + } + +#ifndef NDEBUG + MGlobal::displayInfo( "HDRFlow: failed to open." ); +#endif + + return MS::kFailure; +} + +MStatus image_reader::load( MImage& image, unsigned int idx ) +{ +#ifndef NDEBUG + MGlobal::displayInfo( "HDRFlow: loading image..." ); +#endif + + im_ = il::convert( im_, L"r32g32b32a32f" ); + if( !im_ ) return MS::kFailure; + + int width = im_->width( ); + int height = im_->height( ); + int pitch = im_->pitch( ); + int linesize = im_->linesize( ); + + image.create( im_->width( ), im_->height( ), 4, MImage::kFloat ); + + const float* src = reinterpret_cast<const float*>( im_->data( ) ); + float* dst = image.floatPixels( ); + + for( int i = 0; i < height; ++i ) + { + memcpy( dst, src, im_->linesize( ) * sizeof( float ) ); + + src += pitch; + dst += width * 4; + } + +#ifndef NDEBUG + MGlobal::displayInfo( "HDRFlow: image loaded." ); +#endif + + return MS::kSuccess; +} + +MStatus image_reader::close( ) +{ + im_.reset( ); + + return MS::kSuccess; +} + +} } } + +extern "C" MStatus initializePlugin( MObject obj ) +{ +#ifndef NDEBUG + MGlobal::displayInfo( "HDRFlow: initialising ..." ); +#endif + + MFnPlugin plugin( obj, "com.cryogenicgraphics", "8.0", "Any" ); + MStringArray extensions; + extensions.append( "hdr" ); + CHECK_MSTATUS( plugin.registerImageFile( "HDRFlow", hdrflow::extras::mfn::image_reader::creator, extensions ) ); + + pl::init( ); + + return MS::kSuccess; +} + +extern "C" MStatus uninitializePlugin( MObject obj ) +{ + MFnPlugin plugin( obj ); + CHECK_MSTATUS( plugin.deregisterImageFile( "HDRFlow" ) ); + + return MS::kSuccess; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <gl...@us...> - 2008-02-18 20:54:48
|
Revision: 413 http://hdrflow.svn.sourceforge.net/hdrflow/?rev=413&view=rev Author: glslang Date: 2008-02-18 12:54:44 -0800 (Mon, 18 Feb 2008) Log Message: ----------- + convert hdrflow maya to ml Modified Paths: -------------- trunk/lib/extras/src/imf/mfn/mfn.cpp trunk/lib/extras/src/imf/mfn/readers_vc8.vcproj Modified: trunk/lib/extras/src/imf/mfn/mfn.cpp =================================================================== --- trunk/lib/extras/src/imf/mfn/mfn.cpp 2008-02-10 17:22:50 UTC (rev 412) +++ trunk/lib/extras/src/imf/mfn/mfn.cpp 2008-02-18 20:54:44 UTC (rev 413) @@ -21,39 +21,18 @@ #include <openpluginlib/pl/utf8_utils.hpp> #include <openpluginlib/pl/stream.hpp> -#include <openimagelib/il/openimagelib_plugin.hpp> +#include <openimagelib/il/il.hpp> +#include <openmedialib/ml/openmedialib_plugin.hpp> +#include <openmedialib/ml/utilities.hpp> #include <imf/mfn/config.hpp> namespace pl = olib::openpluginlib; namespace il = olib::openimagelib::il; +namespace ml = olib::openmedialib::ml; namespace hdrflow { namespace extras { namespace mfn { -namespace -{ - struct query_traits - { - query_traits( const pl::wstring& filename ) - : filename_( filename ) - { } - - pl::wstring libname( ) const - { return L"openimagelib"; } - - pl::wstring to_match( ) const - { return filename_; } - - pl::wstring type( ) const - { return L""; } - - int merit( ) const - { return 0; } - - pl::wstring filename_; - }; -} - class image_reader : public MPxImageFile { public: @@ -65,7 +44,7 @@ private: pl::string pathname_; - il::image_type_ptr im_; + ml::input_type_ptr input_; }; void* image_reader::creator( ) @@ -76,9 +55,44 @@ MStatus image_reader::open( MString pathname, MImageFileInfo* info ) { #ifndef NDEBUG - MGlobal::displayInfo( "HDRFlow: opening image..." ); + MGlobal::displayInfo( "HDRFlow: opening media stream..." ); #endif + input_ = ml::create_input( pl::to_wstring( pathname.asChar( ) ) ); + if( !input_ ) + return MS::kFailure; + +#ifndef NDEBUG + MGlobal::displayInfo( "HDRFlow: plugin found ..." ); +#endif + + ml::frame_type_ptr frame = input_->fetch( ); + if( !frame ) + return MS::kFailure; + +#ifndef NDEBUG + MGlobal::displayInfo( "HDRFlow: frame found ..." ); +#endif + + il::image_type_ptr im = frame->get_image( ); + if( !im ) + return MS::kFailure; + +#ifndef NDEBUG + MGlobal::displayInfo( "HDRFlow: image stream found ..." ); +#endif + + if( info ) + { + info->width( im->width( ) ); + info->height( im->height( ) ); + info->channels( 4 ); // always assumes alpha/matte exists + info->numberOfImages( input_->get_frames( ) ); + info->pixelType( MImage::kFloat ); // convert everything to float by default + } + + return MS::kSuccess; +/* typedef pl::discovery<query_traits> discovery; discovery plugins( query_traits( pl::to_wstring( pathname.asChar( ) ) ) ); @@ -128,7 +142,7 @@ MGlobal::displayInfo( "HDRFlow: failed to open." ); #endif - return MS::kFailure; + return MS::kFailure;*/ } MStatus image_reader::load( MImage& image, unsigned int idx ) @@ -137,10 +151,15 @@ MGlobal::displayInfo( "HDRFlow: loading image..." ); #endif - il::image_type_ptr im = il::convert( im_, L"r32g32b32a32f" ); + input_->seek( idx ); + ml::frame_type_ptr frame = input_->fetch( ); + if( !frame ) + return MS::kFailure; + + il::image_type_ptr im = il::convert( frame->get_image( ), L"r32g32b32a32f" ); if( !im ) { - im = il::convert( il::convert( im_, L"b8g8r8a8" ), L"r32g32b32a32f" ); + im = il::convert( il::convert( frame->get_image( ), L"b8g8r8a8" ), L"r32g32b32a32f" ); if( !im ) { #ifndef NDEBUG @@ -164,7 +183,7 @@ for( int i = 0; i < height; ++i ) { - memcpy( dst, src, im->linesize( ) * sizeof( float ) ); + memcpy( dst, src, linesize * sizeof( float ) ); src += pitch; dst += width * 4; @@ -183,7 +202,7 @@ MGlobal::displayInfo( "HDRFlow: closing..." ); #endif - im_.reset( ); + input_.reset( ); return MS::kSuccess; } Modified: trunk/lib/extras/src/imf/mfn/readers_vc8.vcproj =================================================================== --- trunk/lib/extras/src/imf/mfn/readers_vc8.vcproj 2008-02-10 17:22:50 UTC (rev 412) +++ trunk/lib/extras/src/imf/mfn/readers_vc8.vcproj 2008-02-18 20:54:44 UTC (rev 413) @@ -52,6 +52,7 @@ WarningLevel="4" Detect64BitPortabilityProblems="true" DebugInformationFormat="4" + DisableSpecificWarnings="4503" /> <Tool Name="VCManagedResourceCompilerTool" @@ -133,6 +134,7 @@ WarningLevel="4" Detect64BitPortabilityProblems="true" DebugInformationFormat="3" + DisableSpecificWarnings="4503" /> <Tool Name="VCManagedResourceCompilerTool" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |