ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/ra_pfm.csh
(Generate patch)

Comparing ray/src/px/ra_pfm.csh (file contents):
Revision 2.1 by greg, Thu Nov 25 14:47:03 2004 UTC vs.
Revision 2.4 by greg, Fri Jan 14 06:40:54 2005 UTC

# Line 4 | Line 4
4   # Convert to/from Poskanzer Float Map image format using pvalue
5   #
6   if (`uname -p` == powerpc) then
7 <        set format="-dF"
7 >        set machend=big
8   else
9 <        set format="-df"
9 >        set machend=little
10   endif
11   while ($#argv > 0)
12          if ("$argv[1]" == "-r") then
13                  set reverse
14 <        else
14 >        else if (! $?inp) then
15                  set inp="$argv[1]"
16 +        else if (! $?out) then
17 +                set out="$argv[1]"
18 +        else
19 +                goto userr
20          endif
21          shift argv
22   end
# Line 20 | Line 24 | if ($?reverse) then
24          if (! $?inp) then
25                  goto userr
26          endif
27 +        set opt=""
28          set hl="`head -3 $inp:q`"
29 <        if ("$hl[1]" != "PF") then
29 >        if ("$hl[1]" == "Pf") then
30 >                set opt=($opt -b)
31 >        else if ("$hl[1]" != "PF") then
32                  echo "Input not a Poskanzer Float Map"
33                  exit 1
34          endif
35 +        if (`ev "if($hl[3],1,0)"`) then
36 +                set filend=big
37 +        else
38 +                set filend=little
39 +        endif
40 +        if ($filend != $machend) then
41 +                set opt=($opt -dF)
42 +        else
43 +                set opt=($opt -df)
44 +        endif
45          set res=($hl[2])
46 <        tail +4 $inp:q | pvalue -r -h -y $res[1] +x $res[2] $format
46 >        if ($?out) then
47 >                tail +4 $inp:q | pvalue -r -h $opt +y $res[2] +x $res[1] > $out:q
48 >        else
49 >                tail +4 $inp:q | pvalue -r -h $opt +y $res[2] +x $res[1]
50 >        endif
51          exit $status
52   endif
53   if (! $?inp) then
54          goto userr
55   endif
56   set res=(`getinfo -d < $inp:q`)
57 < echo PF
58 < echo $res[4] $res[2]
59 < echo "-1.000000"
60 < pvalue -h -H $format $inp:q
57 > if ($?out) then
58 >        ( echo PF ; echo $res[4] $res[2] ) > $out:q
59 >        if ($machend == little) then
60 >                echo "-1.000000" >> $out:q
61 >        else
62 >                echo "1.000000" >> $out:q
63 >        endif
64 >        if ("$res[1]" == "-Y") then
65 >                pflip -v $inp:q | pvalue -h -H -df >> $out:q
66 >        else
67 >                pvalue -h -H -df $inp:q >> $out:q
68 >        endif
69 > else
70 >        echo PF
71 >        echo $res[4] $res[2]
72 >        if ($machend == little) then
73 >                echo "-1.000000"
74 >        else
75 >                echo "1.000000"
76 >        endif
77 >        if ("$res[1]" == "-Y") then
78 >                pflip -v $inp:q | pvalue -h -H -df
79 >        else
80 >                pvalue -h -H -df $inp:q
81 >        endif
82 > endif
83   exit $status
84   userr:
85 < echo "Usage: $0 input.pfm > output.hdr"
86 < echo "   or: $0 -r input.hdr > output.pfm"
85 > echo "Usage: $0 input.pfm [output.hdr]"
86 > echo "   or: $0 -r input.hdr [output.pfm]"
87   exit 1

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines