5 |
|
* General matrix operations. |
6 |
|
*/ |
7 |
|
|
8 |
– |
#include <stdio.h> |
8 |
|
#include <stdlib.h> |
10 |
– |
#include <string.h> |
11 |
– |
#include <fcntl.h> |
9 |
|
#include <errno.h> |
10 |
|
#include "rtio.h" |
11 |
|
#include "platform.h" |
24 |
|
if ((nr <= 0) | (nc <= 0) | (n <= 0)) |
25 |
|
return(NULL); |
26 |
|
dnew = (RMATRIX *)malloc(sizeof(RMATRIX)-sizeof(dnew->mtx) + |
27 |
< |
sizeof(dnew->mtx[0])*(n*nr*nc)); |
27 |
> |
sizeof(dnew->mtx[0])*n*nr*nc); |
28 |
|
if (!dnew) |
29 |
|
return(NULL); |
30 |
|
dnew->nrows = nr; dnew->ncols = nc; dnew->ncomp = n; |
100 |
|
ip->swapin = (nativebigendian() != i); |
101 |
|
return(0); |
102 |
|
} |
103 |
+ |
if (isexpos(s)) { |
104 |
+ |
double d = exposval(s); |
105 |
+ |
scalecolor(ip->mtx, d); |
106 |
+ |
return(0); |
107 |
+ |
} |
108 |
+ |
if (iscolcor(s)) { |
109 |
+ |
COLOR ctmp; |
110 |
+ |
colcorval(ctmp, s); |
111 |
+ |
multcolor(ip->mtx, ctmp); |
112 |
+ |
return(0); |
113 |
+ |
} |
114 |
|
if (!formatval(fmt, s)) { |
115 |
|
rmx_addinfo(ip, s); |
116 |
|
return(0); |
161 |
|
static int |
162 |
|
rmx_load_double(RMATRIX *rm, FILE *fp) |
163 |
|
{ |
164 |
< |
int i, j; |
164 |
> |
int i; |
165 |
|
|
166 |
< |
for (i = 0; i < rm->nrows; i++) |
167 |
< |
for (j = 0; j < rm->ncols; j++) { |
168 |
< |
if (getbinary(&rmx_lval(rm,i,j,0), sizeof(double), rm->ncomp, fp) != rm->ncomp) |
169 |
< |
return(0); |
166 |
> |
if ((char *)&rmx_lval(rm,1,0,0) - (char *)&rmx_lval(rm,0,0,0) != |
167 |
> |
sizeof(double)*rm->ncols*rm->ncomp) { |
168 |
> |
fputs("Code error in rmx_load_double()\n", stderr); |
169 |
> |
exit(1); |
170 |
> |
} |
171 |
> |
for (i = 0; i < rm->nrows; i++) { |
172 |
> |
if (getbinary(&rmx_lval(rm,i,0,0), sizeof(double)*rm->ncomp, |
173 |
> |
rm->ncols, fp) != rm->ncols) |
174 |
> |
return(0); |
175 |
|
if (rm->swapin) |
176 |
< |
swap64((char *)&rmx_lval(rm,i,j,0), rm->ncomp); |
177 |
< |
} |
176 |
> |
swap64((char *)&rmx_lval(rm,i,0,0), rm->ncols*rm->ncomp); |
177 |
> |
} |
178 |
|
return(1); |
179 |
|
} |
180 |
|
|
242 |
|
dinfo.dtype = DTascii; /* assumed w/o FORMAT */ |
243 |
|
dinfo.swapin = 0; |
244 |
|
dinfo.info = NULL; |
245 |
+ |
dinfo.mtx[0] = dinfo.mtx[1] = dinfo.mtx[2] = 1.; |
246 |
|
if (getheader(fp, get_dminfo, &dinfo) < 0) { |
247 |
|
fclose(fp); |
248 |
|
return(NULL); |
289 |
|
case DTxyze: |
290 |
|
if (!rmx_load_rgbe(dnew, fp)) |
291 |
|
goto loaderr; |
292 |
< |
dnew->dtype = dinfo.dtype; |
292 |
> |
dnew->dtype = dinfo.dtype; /* undo exposure? */ |
293 |
> |
if ((dinfo.mtx[0] != 1.) | (dinfo.mtx[1] != 1.) | |
294 |
> |
(dinfo.mtx[2] != 1.)) { |
295 |
> |
dinfo.mtx[0] = 1./dinfo.mtx[0]; |
296 |
> |
dinfo.mtx[1] = 1./dinfo.mtx[1]; |
297 |
> |
dinfo.mtx[2] = 1./dinfo.mtx[2]; |
298 |
> |
rmx_scale(dnew, dinfo.mtx); |
299 |
> |
} |
300 |
|
break; |
301 |
|
default: |
302 |
|
goto loaderr; |
676 |
|
return(NULL); |
677 |
|
if (msrc->info) { |
678 |
|
char buf[128]; |
679 |
< |
sprintf(buf, "Applied %dx%d matrix transform\n", |
679 |
> |
sprintf(buf, "Applied %dx%d component transform\n", |
680 |
|
dnew->ncomp, msrc->ncomp); |
681 |
|
rmx_addinfo(dnew, msrc->info); |
682 |
|
rmx_addinfo(dnew, buf); |