[Hdrflow-svn] SF.net SVN: hdrflow: [287] trunk/lib/extras/src/raw
Status: Pre-Alpha
Brought to you by:
glslang
From: <gl...@us...> - 2007-09-01 14:36:19
|
Revision: 287 http://hdrflow.svn.sourceforge.net/hdrflow/?rev=287&view=rev Author: glslang Date: 2007-09-01 07:36:14 -0700 (Sat, 01 Sep 2007) Log Message: ----------- + raw importer plugin functional Modified Paths: -------------- trunk/lib/extras/src/raw/Makefile.am trunk/lib/extras/src/raw/dcraw.c trunk/lib/extras/src/raw/raw.cpp trunk/lib/extras/src/raw/raw_vc8.vcproj Added Paths: ----------- trunk/lib/extras/src/raw/raw_plugin.opl Modified: trunk/lib/extras/src/raw/Makefile.am =================================================================== --- trunk/lib/extras/src/raw/Makefile.am 2007-08-30 22:38:33 UTC (rev 286) +++ trunk/lib/extras/src/raw/Makefile.am 2007-09-01 14:36:14 UTC (rev 287) @@ -13,10 +13,17 @@ libhdrflow_extras_raw_la_CXXFLAGS = \ $(BOOST_INCLUDE_PATH) \ - -I$(top_builddir)/../openlibraries/src \ - $(OFX_INCLUDE_PATH) + -I$(top_builddir)/../openlibraries/src libhdrflow_extras_raw_la_CFLAGS = \ -DNO_JPEG \ -DNO_LCMS +libhdrflow_extras_raw_la_LIBADD = \ + $(top_builddir)/../openlibraries/src/openpluginlib/pl/libopenpluginlib_pl.la \ + $(top_builddir)/../openlibraries/src/openimagelib/il/libopenimagelib_il.la + +libhdrflow_extras_raw_ladir = $(EXTRAS_PLUGINPATH) +libhdrflow_extras_raw_la_DATA = raw_plugin.opl + +nobase_dist_libhdrflow_extras_raw_la_DATA = raw_plugin.opl Modified: trunk/lib/extras/src/raw/dcraw.c =================================================================== --- trunk/lib/extras/src/raw/dcraw.c 2007-08-30 22:38:33 UTC (rev 286) +++ trunk/lib/extras/src/raw/dcraw.c 2007-09-01 14:36:14 UTC (rev 287) @@ -7395,7 +7395,7 @@ free (ppm); } -int CLASS main_ (int argc, char **argv) +int CLASS dcraw_ (int argc, char **argv) { int arg, status=0, user_flip=-1, user_black=-1, user_qual=-1; int timestamp_only=0, thumbnail_only=0, identify_only=0; Modified: trunk/lib/extras/src/raw/raw.cpp =================================================================== --- trunk/lib/extras/src/raw/raw.cpp 2007-08-30 22:38:33 UTC (rev 286) +++ trunk/lib/extras/src/raw/raw.cpp 2007-09-01 14:36:14 UTC (rev 287) @@ -11,7 +11,9 @@ #include <windows.h> #endif +#include <openpluginlib/pl/utf8_utils.hpp> #include <openpluginlib/pl/pcos/property_container.hpp> + #include <openimagelib/il/openimagelib_plugin.hpp> namespace pl = olib::openpluginlib; @@ -20,13 +22,61 @@ namespace hdrflow { namespace extras { namespace raw { -extern "C" int main_( int argc, char** argv ); +extern "C" int dcraw_( int argc, char** argv ); namespace { - bool dcraw( pcos::property_container properties ) + struct query_traits { - return true; + 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_; + }; + + il::image_type_ptr dcraw( pcos::property_container properties ) // TODO: change to ptr when pcos moves to proper copy semantics + { + pl::string tiff = properties.get_property_with_key( pcos::key::from_string( "tiff_output" ) ).value<pl::string>( ); + pl::string path = properties.get_property_with_key( pcos::key::from_string( "path" ) ).value<pl::string>( ); + + std::vector<const char*> args; + args.push_back( "dcraw" ); + args.push_back( tiff.c_str( ) ); + args.push_back( path.c_str( ) ); + + if( dcraw_( static_cast<int>( args.size( ) ), const_cast<char**>( &args[ 0 ] ) ) ) + return il::image_type_ptr( ); + + pl::string pathname( path.begin( ), path.find_last_of( "." ) ); + pathname += ".tiff"; + + typedef pl::discovery<query_traits> discovery; + + discovery plugins( query_traits( pl::to_wstring( pathname ) ) ); + if( plugins.empty( ) ) + return il::image_type_ptr( ); + + 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 ) + return plug->load( pl::make_stream( pathname, std::ios::in ) ); + } + + return il::image_type_ptr( ); } } @@ -54,15 +104,48 @@ , which_raw_( pcos::key::from_string( "which_raw" ) ) , sRGB_output_( pcos::key::from_string( "sRGB_output" ) ) , tiff_output_( pcos::key::from_string( "tiff_output" ) ) - { } + , path_( pcos::key::from_string( "path" ) ) + { + set_raw_properties( ); + } - virtual il::image_type_ptr load( pl::stream_ptr ) - { return il::image_type_ptr( ); } + virtual il::image_type_ptr load( pl::stream_ptr stream ) + { + raw_props_.get_property_with_key( pcos::key::from_string( "path" ) ) = stream->path( ); + return dcraw( raw_props_ ); + } virtual bool store( pl::stream_ptr, il::image_type_ptr ) { return false; } private: + void set_raw_properties( ) + { + raw_props_.append( verbose_ ); + raw_props_.append( thumbnail_ ); + raw_props_.append( camera_white_balance_ ); + raw_props_.append( average_white_balance_ ); + raw_props_.append( average_grey_box_white_balance_ ); + raw_props_.append( user_white_balance_ ); + raw_props_.append( brightness_ ); + raw_props_.append( wavelet_denoising_threshold_ ); + raw_props_.append( black_point_ ); + raw_props_.append( highlight_mode_ ); + raw_props_.append( flip_image_ ); + raw_props_.append( output_colorspace_ ); + raw_props_.append( document_mode_ ); + raw_props_.append( stretch_rotate_ ); + raw_props_.append( interpolation_quality_ ); + raw_props_.append( half_size_ ); + raw_props_.append( four_colour_interpolation_ ); + raw_props_.append( which_raw_ ); + raw_props_.append( sRGB_output_ ); + raw_props_.append( tiff_output_ = pl::string( "-T" ) ); + raw_props_.append( path_ = pl::string( "" ) ); + } + +private: + pcos::property_container raw_props_; pcos::property verbose_; pcos::property thumbnail_; pcos::property camera_white_balance_; @@ -83,29 +166,36 @@ pcos::property which_raw_; pcos::property sRGB_output_; pcos::property tiff_output_; + pcos::property path_; }; } } } +#ifdef WIN32 +# define RAW_DECLSPEC __declspec( dllexport ) +#else +# define RAW_DECLSPEC __attribute__( ( visibility( "default" ) ) ) +#endif + extern "C" { - bool openplugin_init( void ) + RAW_DECLSPEC bool openplugin_init( void ) { return true; } - bool openplugin_uninit( void ) + RAW_DECLSPEC bool openplugin_uninit( void ) { return true; } - bool openplugin_create_plugin( const char*, pl::openplugin** plug ) + RAW_DECLSPEC bool openplugin_create_plugin( const char*, pl::openplugin** plug ) { *plug = new hdrflow::extras::raw::raw_plugin; return true; } - void openplugin_destroy_plugin( pl::openplugin* plug ) + RAW_DECLSPEC void openplugin_destroy_plugin( pl::openplugin* plug ) { delete static_cast<hdrflow::extras::raw::raw_plugin*>( plug ); } Added: trunk/lib/extras/src/raw/raw_plugin.opl =================================================================== --- trunk/lib/extras/src/raw/raw_plugin.opl (rev 0) +++ trunk/lib/extras/src/raw/raw_plugin.opl 2007-09-01 14:36:14 UTC (rev 287) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<openlibraries version="1.0"> + <!-- plugins go here --> + <openimagelib name="oil" version="0.2.0"> + <plugin name="HDRFlow Raw plugin" type="input" in_filter="*.raw *.cr2" extension='".*\.raw", ".*\.cr2"' merit="0" filename='"libhdrflow_raw.so", "libhdrflow_raw.dylib", "hdrflow_raw-vc80-d-0_1_0.dll", "hdrflow_raw-vc80-r-0_1_0.dll"'/> + </openimagelib> +</openlibraries> Property changes on: trunk/lib/extras/src/raw/raw_plugin.opl ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/lib/extras/src/raw/raw_vc8.vcproj =================================================================== --- trunk/lib/extras/src/raw/raw_vc8.vcproj 2007-08-30 22:38:33 UTC (rev 286) +++ trunk/lib/extras/src/raw/raw_vc8.vcproj 2007-09-01 14:36:14 UTC (rev 287) @@ -41,7 +41,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)\..\openlibraries\src";"C:\Boost\include\boost-1_34"" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;RAW_EXPORTS;HAVE_FLEX_STRING;NO_JPEG;NO_LCMS" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;RAW_EXPORTS;HAVE_FLEX_STRING;_CRT_SECURE_NO_WARNINGS;NO_JPEG;NO_LCMS" MinimalRebuild="true" ExceptionHandling="2" BasicRuntimeChecks="3" @@ -51,6 +51,7 @@ WarningLevel="4" Detect64BitPortabilityProblems="true" DebugInformationFormat="4" + DisableSpecificWarnings="4503" /> <Tool Name="VCManagedResourceCompilerTool" @@ -124,7 +125,7 @@ <Tool Name="VCCLCompilerTool" AdditionalIncludeDirectories=""$(SolutionDir)\..\openlibraries\src";"C:\Boost\include\boost-1_34"" - PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;RAW_EXPORTS;HAVE_FLEX_STRING;NO_JPEG;NO_LCMS" + PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;RAW_EXPORTS;HAVE_FLEX_STRING;_CRT_SECURE_NO_WARNINGS;NO_JPEG;NO_LCMS" ExceptionHandling="2" RuntimeLibrary="2" BufferSecurityCheck="false" @@ -134,6 +135,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. |