"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/octave/pfsput.cpp" between
pfstools-2.1.0.tgz and pfstools-2.2.0.tgz

About: pfstools are a set of command line programs (and one GUI program) for reading, writing, manipulating, and viewing high-dynamic range (HDR) images and video frames (similar as the netpbm package does for low-dynamic range images).

pfsput.cpp  (pfstools-2.1.0.tgz):pfsput.cpp  (pfstools-2.2.0.tgz)
skipping to change at line 38 skipping to change at line 38
#include <octave/oct.h> #include <octave/oct.h>
#include <octave/oct-stream.h> #include <octave/oct-stream.h>
#include <octave/ov-struct.h> #include <octave/ov-struct.h>
#include <octave/Cell.h> #include <octave/Cell.h>
//#include "../../config.h" // conflicts with config. h from octave distribution //#include "../../config.h" // conflicts with config. h from octave distribution
#include <string> #include <string>
#include <pfs.h> #include <pfs.h>
#if OCTAVE_MAJOR_VERSION < 4 || (OCTAVE_MAJOR_VERSION == 4 && OCTAVE_MINOR_VERSI
ON < 4)
#define isstruct is_map
#endif
#define SCRIPT_NAME "pfsput" #define SCRIPT_NAME "pfsput"
static const char *helpString = static const char *helpString =
#include "pfsput_help.h" #include "pfsput_help.h"
DEFUN_DLD( pfsput, args, , helpString) DEFUN_DLD( pfsput, args, , helpString)
{ {
octave_value_list retval; octave_value_list retval;
int nargin = args.length(); int nargin = args.length();
if( nargin != 1 || !args(0).is_map() ) if( nargin != 1 || !args(0).isstruct() )
{ {
error( SCRIPT_NAME ": Improper usage!"); error( SCRIPT_NAME ": Improper usage!");
return retval; return retval;
} }
octave_map pfsStream = args(0).map_value(); octave_map pfsStream = args(0).map_value();
octave_scalar_map::const_iterator itFH = pfsStream.seek( "FH" ); octave_scalar_map::const_iterator itFH = pfsStream.seek( "FH" );
if( itFH == pfsStream.end() || if( itFH == pfsStream.end() ||
!pfsStream.contents( itFH )(0).is_real_scalar() ) !pfsStream.contents( itFH )(0).is_real_scalar() )
skipping to change at line 101 skipping to change at line 105
} }
width = (int)pfsStream.contents( itCols )(0).double_value(); width = (int)pfsStream.contents( itCols )(0).double_value();
height = (int)pfsStream.contents( itRows )(0).double_value(); height = (int)pfsStream.contents( itRows )(0).double_value();
} }
// Get channels // Get channels
octave_map channels; octave_map channels;
{ {
octave_scalar_map::const_iterator itChannels = pfsStream.seek( "channels" ); octave_scalar_map::const_iterator itChannels = pfsStream.seek( "channels" );
if( itChannels == pfsStream.end() || if( itChannels == pfsStream.end() ||
!pfsStream.contents( itChannels )(0).is_map() ) !pfsStream.contents( itChannels )(0).isstruct() )
{ {
error( SCRIPT_NAME ": 'channels' field missing in the structure or it has wrong type"); error( SCRIPT_NAME ": 'channels' field missing in the structure or it has wrong type");
return retval; return retval;
} }
channels = pfsStream.contents( itChannels )(0).map_value(); channels = pfsStream.contents( itChannels )(0).map_value();
} }
try { try {
pfs::DOMIO ctx; pfs::DOMIO ctx;
pfs::Frame *frame = ctx.createFrame( width, height ); pfs::Frame *frame = ctx.createFrame( width, height );
skipping to change at line 140 skipping to change at line 144
for( int r = 0; r < pfsChannel->getRows(); r++ ) for( int r = 0; r < pfsChannel->getRows(); r++ )
for( int c = 0; c < pfsChannel->getCols(); c++ ) { for( int c = 0; c < pfsChannel->getCols(); c++ ) {
(*pfsChannel)(index++) = channelData(r,c); (*pfsChannel)(index++) = channelData(r,c);
} }
} }
// Copy frame tags // Copy frame tags
{ {
octave_scalar_map::const_iterator itTags = pfsStream.seek( "tags" ); octave_scalar_map::const_iterator itTags = pfsStream.seek( "tags" );
if( itTags != pfsStream.end() ) { if( itTags != pfsStream.end() ) {
if( !pfsStream.contents( itTags )(0).is_map() ) if( !pfsStream.contents( itTags )(0).isstruct() )
{ {
throw pfs::Exception( "'tags' field must be a structure" ); throw pfs::Exception( "'tags' field must be a structure" );
} }
octave_map tags = pfsStream.contents( itTags )(0).map_value(); octave_map tags = pfsStream.contents( itTags )(0).map_value();
for( octave_scalar_map::iterator itTag = tags.begin(); itTag != tags.end (); itTag++ ) { for( octave_scalar_map::iterator itTag = tags.begin(); itTag != tags.end (); itTag++ ) {
std::string tagName = tags.key(itTag); std::string tagName = tags.key(itTag);
if( !tags.contents( itTag )(0).is_string() ) if( !tags.contents( itTag )(0).is_string() )
throw pfs::Exception( "all tags must be given as strings" ); throw pfs::Exception( "all tags must be given as strings" );
std::string tagValue = tags.contents( itTag )(0).string_value(); std::string tagValue = tags.contents( itTag )(0).string_value();
frame->getTags()->setString( tagName.c_str(), tagValue.c_str() ); frame->getTags()->setString( tagName.c_str(), tagValue.c_str() );
} }
} }
} }
// Copy channel tags // Copy channel tags
{ {
octave_scalar_map::const_iterator itChTags = pfsStream.seek( "channelTags" ); octave_scalar_map::const_iterator itChTags = pfsStream.seek( "channelTags" );
if( itChTags != pfsStream.end() ) { if( itChTags != pfsStream.end() ) {
if( !pfsStream.contents( itChTags )(0).is_map() ) if( !pfsStream.contents( itChTags )(0).isstruct() )
{ {
throw pfs::Exception( "'channelTags' field must be a structure" ); throw pfs::Exception( "'channelTags' field must be a structure" );
} }
octave_map tagChannels = pfsStream.contents( itChTags )(0).map_value(); octave_map tagChannels = pfsStream.contents( itChTags )(0).map_value();
for( octave_scalar_map::iterator itCh = tagChannels.begin(); itCh != tag Channels.end(); itCh++ ) { for( octave_scalar_map::iterator itCh = tagChannels.begin(); itCh != tag Channels.end(); itCh++ ) {
std::string channelName = tagChannels.key(itCh); std::string channelName = tagChannels.key(itCh);
if( !tagChannels.contents( itCh )(0).is_map() ) { if( !tagChannels.contents( itCh )(0).isstruct() ) {
throw pfs::Exception( "each channelTags file must be a structure" ); throw pfs::Exception( "each channelTags file must be a structure" );
} }
pfs::Channel *pfsChannel = frame->getChannel( channelName.c_str() ); pfs::Channel *pfsChannel = frame->getChannel( channelName.c_str() );
if( pfsChannel == NULL ) { if( pfsChannel == NULL ) {
throw pfs::Exception( "can not set channel tag if channel is missing " ); throw pfs::Exception( "can not set channel tag if channel is missing " );
} }
octave_map tags = tagChannels.contents( itCh )(0).map_value(); octave_map tags = tagChannels.contents( itCh )(0).map_value();
for( octave_scalar_map::iterator itTag = tags.begin(); itTag != tags.e nd(); itTag++ ) { for( octave_scalar_map::iterator itTag = tags.begin(); itTag != tags.e nd(); itTag++ ) {
std::string tagName = tags.key(itTag); std::string tagName = tags.key(itTag);
skipping to change at line 194 skipping to change at line 198
} }
} }
} }
ctx.writeFrame( frame, fh ); ctx.writeFrame( frame, fh );
ctx.freeFrame( frame ); ctx.freeFrame( frame );
} }
catch( pfs::Exception ex ) catch( pfs::Exception ex )
{ {
char error_message[100]; error( "%s: %s", SCRIPT_NAME, ex.getMessage() );
sprintf( error_message, "%s: %s", SCRIPT_NAME, ex.getMessage() );
error( error_message );
} }
return retval; return retval;
} }
 End of changes. 7 change blocks. 
8 lines changed or deleted 11 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)