[Hdrflow-svn] SF.net SVN: hdrflow: [331] trunk/lib
Status: Pre-Alpha
Brought to you by:
glslang
|
From: <gl...@us...> - 2007-09-30 17:50:39
|
Revision: 331
http://hdrflow.svn.sourceforge.net/hdrflow/?rev=331&view=rev
Author: glslang
Date: 2007-09-30 10:50:37 -0700 (Sun, 30 Sep 2007)
Log Message:
-----------
+ encode to float by normalising to [0.0-1.0]. Workaround for maya plugin release
Modified Paths:
--------------
trunk/lib/extras/src/imf/mfn/mfn.cpp
trunk/lib/extras/src/ppm/ppm_plugin.cpp
trunk/lib/openlibraries/src/openimagelib/il/utility.cpp
Modified: trunk/lib/extras/src/imf/mfn/mfn.cpp
===================================================================
--- trunk/lib/extras/src/imf/mfn/mfn.cpp 2007-09-30 16:10:39 UTC (rev 330)
+++ trunk/lib/extras/src/imf/mfn/mfn.cpp 2007-09-30 17:50:37 UTC (rev 331)
@@ -135,28 +135,32 @@
MGlobal::displayInfo( "HDRFlow: loading image..." );
#endif
- im_ = il::convert( im_, L"r32g32b32a32f" );
- if( !im_ )
+ il::image_type_ptr im = il::convert( im_, L"r32g32b32a32f" );
+ if( !im )
{
+ im = il::convert( il::convert( im_, L"b8g8r8a8" ), L"r32g32b32a32f" );
+ if( !im )
+ {
#ifndef NDEBUG
- MGlobal::displayInfo( "HDRFlow: Internal Error: conversion to floating point format failed. Please report to su...@cr...." );
+ MGlobal::displayInfo( "HDRFlow: Internal Error: conversion to floating point format failed. Please report to su...@cr...." );
#endif
- return MS::kFailure;
+ return MS::kFailure;
+ }
}
- int width = im_->width( );
- int height = im_->height( );
- int pitch = im_->pitch( );
- int linesize = im_->linesize( );
+ 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 );
+ image.create( im->width( ), im->height( ), 4, MImage::kFloat );
- const float* src = reinterpret_cast<const float*>( im_->data( ) );
+ 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 ) );
+ memcpy( dst, src, im->linesize( ) * sizeof( float ) );
src += pitch;
dst += width * 4;
Modified: trunk/lib/extras/src/ppm/ppm_plugin.cpp
===================================================================
--- trunk/lib/extras/src/ppm/ppm_plugin.cpp 2007-09-30 16:10:39 UTC (rev 330)
+++ trunk/lib/extras/src/ppm/ppm_plugin.cpp 2007-09-30 17:50:37 UTC (rev 331)
@@ -46,14 +46,16 @@
const unsigned short* data = reinterpret_cast<const unsigned short*>( stream->data( ) );
il::image_type::pointer texels = im->data( );
-
+
+ float one_over_65535 = 1.0f / 65535.0f;
+
for( int i = 0; i < height; ++i )
{
for( int j = 0; j < width; ++j )
{
- ( ( float* ) texels )[ 0 ] = *data++;
- ( ( float* ) texels )[ 1 ] = *data++;
- ( ( float* ) texels )[ 2 ] = *data++;
+ ( ( float* ) texels )[ 0 ] = *data++ * one_over_65535;
+ ( ( float* ) texels )[ 1 ] = *data++ * one_over_65535;
+ ( ( float* ) texels )[ 2 ] = *data++ * one_over_65535;
( ( float* ) texels )[ 3 ] = 1.0f;
texels += 4 * sizeof( float );
Modified: trunk/lib/openlibraries/src/openimagelib/il/utility.cpp
===================================================================
--- trunk/lib/openlibraries/src/openimagelib/il/utility.cpp 2007-09-30 16:10:39 UTC (rev 330)
+++ trunk/lib/openlibraries/src/openimagelib/il/utility.cpp 2007-09-30 17:50:37 UTC (rev 331)
@@ -1695,14 +1695,16 @@
size_type orig_width = width;
+ float one_over_255 = 1.0f / 255.0f;
+
while( height-- )
{
while( width-- )
{
- *dst++ = *( src + 2 );
- *dst++ = *( src + 1 );
- *dst++ = *( src + 0 );
- *dst++ = *( src + 3 );
+ *dst++ = *( src + 2 ) * one_over_255;
+ *dst++ = *( src + 1 ) * one_over_255;
+ *dst++ = *( src + 0 ) * one_over_255;
+ *dst++ = *( src + 3 ) * one_over_255;
src += 4;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|