1 |
– |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* Integer operations on COLR scanlines |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include "copyright.h" |
9 |
+ |
|
10 |
+ |
#include <math.h> |
11 |
|
#include "color.h" |
12 |
|
|
13 |
– |
#define NULL 0 |
14 |
– |
|
13 |
|
extern char *bmalloc(); |
14 |
|
|
15 |
|
#define MAXGSHIFT 31 /* maximum shift for gamma table */ |
18 |
|
|
19 |
|
static BYTE (*g_bval)[256] = NULL; |
20 |
|
|
23 |
– |
extern double pow(); |
21 |
|
|
22 |
< |
|
22 |
> |
int |
23 |
|
setcolrcor(f, a2) /* set brightness correction */ |
24 |
|
double (*f)(); |
25 |
|
double a2; |
41 |
|
} |
42 |
|
|
43 |
|
|
44 |
+ |
int |
45 |
|
setcolrinv(f, a2) /* set inverse brightness correction */ |
46 |
|
double (*f)(); |
47 |
|
double a2; |
56 |
|
/* compute gamb -> colr mapping */ |
57 |
|
i = 0; |
58 |
|
mult = 256.0; |
59 |
< |
for (j = 255; j > 0; j--) { |
60 |
< |
while ((g_mant[j] = mult * (*f)(j/256.0, a2)) < 128) { |
59 |
> |
for (j = 256; j--; ) { |
60 |
> |
while ((g_mant[j] = mult * (*f)((j+.5)/256.0, a2)) < 128) { |
61 |
|
i++; |
62 |
|
mult *= 2.0; |
63 |
|
} |
64 |
|
g_nexp[j] = i; |
65 |
|
} |
68 |
– |
g_mant[0] = 0; |
69 |
– |
g_nexp[0] = COLXS; |
66 |
|
return(0); |
67 |
|
} |
68 |
|
|
69 |
|
|
70 |
+ |
int |
71 |
|
setcolrgam(g) /* set gamma conversion */ |
72 |
|
double g; |
73 |
|
{ |
77 |
|
} |
78 |
|
|
79 |
|
|
80 |
+ |
int |
81 |
|
colrs_gambs(scan, len) /* convert scanline of colrs to gamma bytes */ |
82 |
|
register COLR *scan; |
83 |
|
int len; |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
+ |
int |
131 |
|
gambs_colrs(scan, len) /* convert gamma bytes to colr scanline */ |
132 |
|
register COLR *scan; |
133 |
|
int len; |
164 |
|
} |
165 |
|
|
166 |
|
|
167 |
+ |
void |
168 |
|
shiftcolrs(scan, len, adjust) /* shift a scanline of colors by 2^adjust */ |
169 |
|
register COLR *scan; |
170 |
|
register int len; |
186 |
|
} |
187 |
|
|
188 |
|
|
189 |
+ |
void |
190 |
|
normcolrs(scan, len, adjust) /* normalize a scanline of colrs */ |
191 |
|
register COLR *scan; |
192 |
|
int len; |