| 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 <stdio.h> |
| 11 |
+ |
#include <math.h> |
| 12 |
|
#include "color.h" |
| 13 |
|
|
| 13 |
– |
#define NULL 0 |
| 14 |
– |
|
| 14 |
|
extern char *bmalloc(); |
| 15 |
|
|
| 16 |
|
#define MAXGSHIFT 31 /* maximum shift for gamma table */ |
| 19 |
|
|
| 20 |
|
static BYTE (*g_bval)[256] = NULL; |
| 21 |
|
|
| 23 |
– |
#ifndef pow |
| 24 |
– |
extern double pow(); |
| 25 |
– |
#endif |
| 22 |
|
|
| 23 |
< |
|
| 23 |
> |
int |
| 24 |
|
setcolrcor(f, a2) /* set brightness correction */ |
| 25 |
|
double (*f)(); |
| 26 |
|
double a2; |
| 42 |
|
} |
| 43 |
|
|
| 44 |
|
|
| 45 |
+ |
int |
| 46 |
|
setcolrinv(f, a2) /* set inverse brightness correction */ |
| 47 |
|
double (*f)(); |
| 48 |
|
double a2; |
| 57 |
|
/* compute gamb -> colr mapping */ |
| 58 |
|
i = 0; |
| 59 |
|
mult = 256.0; |
| 60 |
< |
for (j = 255; j > 0; j--) { |
| 61 |
< |
while ((g_mant[j] = mult * (*f)(j/256.0, a2)) < 128) { |
| 60 |
> |
for (j = 256; j--; ) { |
| 61 |
> |
while ((g_mant[j] = mult * (*f)((j+.5)/256.0, a2)) < 128) { |
| 62 |
|
i++; |
| 63 |
|
mult *= 2.0; |
| 64 |
|
} |
| 65 |
|
g_nexp[j] = i; |
| 66 |
|
} |
| 70 |
– |
g_mant[0] = 0; |
| 71 |
– |
g_nexp[0] = COLXS; |
| 67 |
|
return(0); |
| 68 |
|
} |
| 69 |
|
|
| 70 |
|
|
| 71 |
+ |
int |
| 72 |
|
setcolrgam(g) /* set gamma conversion */ |
| 73 |
|
double g; |
| 74 |
|
{ |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
|
| 81 |
+ |
int |
| 82 |
|
colrs_gambs(scan, len) /* convert scanline of colrs to gamma bytes */ |
| 83 |
|
register COLR *scan; |
| 84 |
|
int len; |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
|
| 131 |
+ |
int |
| 132 |
|
gambs_colrs(scan, len) /* convert gamma bytes to colr scanline */ |
| 133 |
|
register COLR *scan; |
| 134 |
|
int len; |
| 165 |
|
} |
| 166 |
|
|
| 167 |
|
|
| 168 |
+ |
void |
| 169 |
|
shiftcolrs(scan, len, adjust) /* shift a scanline of colors by 2^adjust */ |
| 170 |
|
register COLR *scan; |
| 171 |
|
register int len; |
| 187 |
|
} |
| 188 |
|
|
| 189 |
|
|
| 190 |
+ |
void |
| 191 |
|
normcolrs(scan, len, adjust) /* normalize a scanline of colrs */ |
| 192 |
|
register COLR *scan; |
| 193 |
|
int len; |