# HG changeset patch # User Axel Jacobs # Date 1309214555 -3600 # Node ID a9f74601ca3c11ab65d27a41cd84abd3f3a1f368 # Parent 9bae974f3ebd9a52220788e8db4bafcdb4b8afc4 xyzimage seems to work now. Upped status to 2. diff -r 9bae974f3ebd -r a9f74601ca3c bin/xyzimage.pl --- a/bin/xyzimage.pl Mon Jun 27 21:17:24 2011 +0100 +++ b/bin/xyzimage.pl Mon Jun 27 23:42:35 2011 +0100 @@ -6,58 +6,66 @@ use strict; use warnings; -#use Getopt::Long qw(:config no_auto_abbrev no_ignore_case require_order -# We need auto_abbrev for -display and -geometry. -use Getopt::Long qw(:config auto_abbrev no_ignore_case require_order - prefix_pattern=(-)); + use File::Temp qw/ tempdir /; use File::Basename; -my @xiargs; -my @popts; -print $#ARGV . ": " . join(', ', @ARGV) . "\n"; +my @xiargs = (); # Options for ximage +my $popt = ''; # Display primaries (as string) +if( $ENV{DISPLAY_PRIMARIES} ) { + $popt = "-p $ENV{DISPLAY_PRIMARIES}"; +} -#TODO: Don't use Getopt. Parse by hand. -GetOptions( - 'g=f' => sub { push(@xiargs, '-g') }, # ximage: -g gamma - 'c=i' => sub { push(@xiargs, '-c') }, # ximage: -c ncolors - 'geometry=s' => sub { push(@xiargs, '-c') }, # ximage: -geometry geometry - #TODO: deal with =geometry - 'di=s' => sub { push(@xiargs, '-c') }, # ximage: -di display - 'e=s' => sub { push(@xiargs, '-e') }, # ximage: -e exposure +while( $#ARGV ) { + $_ = shift @ARGV; + if( m/-ge\w*/ or m/-di\w*/ or m/-g$/ or m/-c/ or m/-e/ ) { + # The following options all require one qualifier and are passed + # straight on to ximage: + # -geometry (an X11 thing, e.g. 800x600+50+50) + # -di display (an X11 thing) + # -c number of colours + # -g gamma + # -e exposure compensation + push( @xiargs, $_, shift @ARGV ) or + die( "Missing qualifier for $_ option.\n" ); - 'p=f{8}' => \@popts, # ra_xyze: -p display_primaries + } elsif( m/=[\S]{3,}/ or m/o\w{1,}/ ) { + # The qualifier to the -o option is glued to the option. + # Passed straight to ximage: + # -ospec print spec to STDOUT (defaults to -ood) + # =geometry (alternative invocation to -geometry) + push( @xiargs, $_ ); - 'b' => sub { push(@xiargs, '-b') }, # ximage: -b (black+white) - 'd' => sub { push(@xiargs, '-d') }, # ximage: -d (no ditering) - 'm' => sub { push(@xiargs, '-m') }, # ximage: -m (monochrome) - 'f' => sub { push(@xiargs, '-f') }, # ximage: -f (fast refresh) - 's' => sub { push(@xiargs, '-s') }, # ximage: -s (sequential) - #'o*' => sub { push(@xiargs, '-l') }, # ximage: -ospec - -) or die("Error parsing options.\n"); -print $#ARGV . ": " . join(', ', @ARGV) . "\n"; + } elsif( m/-b/ or m/-d/ or m/-m/ or m/-f/ or m/-s/ ) { + # The following switches are passed straight to ximage: + # -b black and white output + # -d no color dithering + # -m monochrome output + # -f fast redraw on (-F to turn it off) + # -s display multiple picture sequentially + push( @xiargs, $_ ); -# Handle display primaries: -# Use -p option, $DISPLAY_PRIMARIES, or nothing (in that order!) -#print "popts: $#popts -> " . join(', ', @popts) . "\n"; -my $popt = ""; -if($#popts != 7) { - if($ENV{'DISPLAY_PRIMARIES'}) { - #print "DISPLAY_PRIMARIES: $ENV{'DISPLAY_PRIMARIES'}\n"; - $popt = '-p ' . $ENV{'DISPLAY_PRIMARIES'}; + } elsif( m/-p/ ) { + # The following option requires eight float qualifiers: + # -p display primaries + my @popts = ('-p'); + for( my $i=0 ; $i<=7 ; $i++ ) { + if( $#ARGV <= 0 ) { + die("Missing qualifier for -p option: Need eight.\n"); + } + push( @popts, shift @ARGV ); + } + $popt = join( ' ', @popts ); + } elsif( m/^-/ ) { + die( "Unknown option: $_\n" ); + } else { + # The remaining command-line args are file names. + last; } -} else { - unshift(@popts, '-p'); - $popt = join(' ', @popts); } -print "popt: $popt\n"; - my $xiarg = join(' ', @xiargs); -print "xiarg: $xiarg\n"; my $td = tempdir( CLEANUP => 0 ); - if ($#ARGV < 0) { # Input is from STDIN: Capture to file open(FH, ">$td/stdin.rad"); @@ -69,19 +77,15 @@ @ARGV = ("$td/stdin.rad"); } -print $#ARGV . ": " . join(', ', @ARGV) . "\n"; - my @files; foreach (@ARGV) { - my ($name, undef, undef) = fileparse($_); - my $cmd = "ra_xyze -r -u $popt $name $td/$name"; - print "cmd: $cmd\n"; + my ($name, $path, $suffix) = fileparse($_); + my $cmd = "ra_xyze -r -u $popt $_ $td/$name"; system("$cmd") == 0 or - die("$0: Error running ra_xyze -r on file $_\n. Exit code: $?\n"); + die("Error running ra_xyze -r on file $_\n"); push(@files, "$td/$name"); } -print "temp dir: $td\n"; -system("ximage $xiarg " . join(' ', @files)); +system "ximage $xiarg " . join(' ', @files); #EOF diff -r 9bae974f3ebd -r a9f74601ca3c status/xyzimage.status --- a/status/xyzimage.status Mon Jun 27 21:17:24 2011 +0100 +++ b/status/xyzimage.status Mon Jun 27 23:42:35 2011 +0100 @@ -9,5 +9,5 @@ # 3 .. port is complete and fully tested (comprehensive test script(s) under tests/) # 4 .. port has been included in Radiance HEAD -STATUS = 1 +STATUS = 2