Revision: 396
http://hdrflow.svn.sourceforge.net/hdrflow/?rev=396&view=rev
Author: glslang
Date: 2008-01-05 13:59:16 -0800 (Sat, 05 Jan 2008)
Log Message:
-----------
+ sRGB lut
Modified Paths:
--------------
trunk/lib/extras/src/lut/lut.cpp
Modified: trunk/lib/extras/src/lut/lut.cpp
===================================================================
--- trunk/lib/extras/src/lut/lut.cpp 2008-01-05 21:43:59 UTC (rev 395)
+++ trunk/lib/extras/src/lut/lut.cpp 2008-01-05 21:59:16 UTC (rev 396)
@@ -18,6 +18,39 @@
namespace hdrflow {
+namespace
+{
+ typedef float ( *unary_float )( float );
+
+ template<typename T, typename F>
+ void fill_3( il::image_type_ptr im, F fn )
+ {
+ int width = im->width( );
+ int height = im->height( );
+ int depth = im->depth( );
+ int pitch = im->pitch( );
+
+ const float sx = 1.0f / ( width - 1.0f );
+
+ T* src = reinterpret_cast<T*>( im->data( ) );
+
+ for( int i = 0; i < depth; ++i )
+ {
+ for( int j = 0; j < height; ++j )
+ {
+ for( int k = 0; k < width; ++k )
+ {
+ src[ k + 0 ] = static_cast<T>( fn( k * sx ) );
+ src[ k + 1 ] = static_cast<T>( fn( k * sx ) );
+ src[ k + 2 ] = static_cast<T>( fn( k * sx ) );
+ }
+
+ src += pitch;
+ }
+ }
+ }
+}
+
class ML_PLUGIN_DECLSPEC lut_input : public ml::input_type
{
public:
@@ -105,33 +138,11 @@
pl::wstring pf = prop_colourspace_.value<pl::wstring>( );
pl::wstring fn = prop_function_.value<pl::wstring>( );
- int width = im->width( );
- int height = im->height( );
- int depth = im->depth( );
- int pitch = im->pitch( );
-
- const float sx = 1.0f / ( width - 1.0f );
-
if( fn == L"sRGB" )
{
if( pf == L"r32g32b32f" )
{
- float* src = reinterpret_cast<float*>( im->data( ) );
-
- for( int i = 0; i < depth; ++i )
- {
- for( int j = 0; j < height; ++j )
- {
- for( int k = 0; k < width; ++k )
- {
- src[ k + 0 ] = il::to_sRGB( k * sx );
- src[ k + 1 ] = il::to_sRGB( k * sx );
- src[ k + 2 ] = il::to_sRGB( k * sx );
- }
-
- src += pitch;
- }
- }
+ fill_3<float, unary_float>( im, il::to_sRGB );
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|