| 1 |
greg |
1.1 |
/* Copyright (c) 1986 Regents of the University of California */
|
| 2 |
|
|
|
| 3 |
|
|
/* SCCSid "$SunId$ LBL" */
|
| 4 |
|
|
|
| 5 |
|
|
/*
|
| 6 |
|
|
* color.h - header for routines using pixel color values.
|
| 7 |
|
|
*
|
| 8 |
|
|
* 12/31/85
|
| 9 |
|
|
*
|
| 10 |
|
|
* Two color representations are used, one for calculation and
|
| 11 |
|
|
* another for storage. Calculation is done with three floats
|
| 12 |
|
|
* for speed. Stored color values use 4 bytes which contain
|
| 13 |
|
|
* three single byte mantissas and a common exponent.
|
| 14 |
|
|
*/
|
| 15 |
|
|
|
| 16 |
|
|
#define RED 0
|
| 17 |
|
|
#define GRN 1
|
| 18 |
|
|
#define BLU 2
|
| 19 |
|
|
#define EXP 3
|
| 20 |
|
|
#define COLXS 128 /* excess used for exponent */
|
| 21 |
|
|
|
| 22 |
|
|
typedef unsigned char BYTE; /* 8-bit unsigned integer */
|
| 23 |
|
|
|
| 24 |
|
|
typedef BYTE COLR[4]; /* red, green, blue, exponent */
|
| 25 |
|
|
|
| 26 |
|
|
#define copycolr(c1,c2) (c1[0]=c2[0],c1[1]=c2[1], \
|
| 27 |
|
|
c1[2]=c2[2],c1[3]=c2[3])
|
| 28 |
|
|
|
| 29 |
|
|
typedef float COLOR[3]; /* red, green, blue */
|
| 30 |
|
|
|
| 31 |
|
|
#define colval(col,pri) ((col)[pri])
|
| 32 |
|
|
|
| 33 |
|
|
#define setcolor(col,r,g,b) ((col)[RED]=(r),(col)[GRN]=(g),(col)[BLU]=(b))
|
| 34 |
|
|
|
| 35 |
|
|
#define copycolor(c1,c2) ((c1)[0]=(c2)[0],(c1)[1]=(c2)[1],(c1)[2]=(c2)[2])
|
| 36 |
|
|
|
| 37 |
|
|
#define scalecolor(col,sf) ((col)[0]*=(sf),(col)[1]*=(sf),(col)[2]*=(sf))
|
| 38 |
|
|
|
| 39 |
|
|
#define addcolor(c1,c2) ((c1)[0]+=(c2)[0],(c1)[1]+=(c2)[1],(c1)[2]+=(c2)[2])
|
| 40 |
|
|
|
| 41 |
|
|
#define multcolor(c1,c2) ((c1)[0]*=(c2)[0],(c1)[1]*=(c2)[1],(c1)[2]*=(c2)[2])
|
| 42 |
|
|
|
| 43 |
|
|
#define bright(col) (.30*(col)[RED]+.59*(col)[GRN]+.11*(col)[BLU])
|
| 44 |
|
|
|
| 45 |
|
|
#define intens(col) ( (col)[0] > (col)[1] \
|
| 46 |
|
|
? (col)[0] > (col)[2] ? (col)[0] : (col)[2] \
|
| 47 |
|
|
: (col)[1] > (col)[2] ? (col)[1] : (col)[2] )
|
| 48 |
|
|
|
| 49 |
greg |
1.3 |
#define colrval(c,p) ( (c)[EXP] ? \
|
| 50 |
|
|
ldexp((c)[p]+.5,(int)(c)[EXP]-(COLXS+8)) : \
|
| 51 |
|
|
0. )
|
| 52 |
|
|
|
| 53 |
|
|
#define norm_bright(c) (int)((77L*(c)[RED]+151L*(c)[GRN]+28L*(c)[BLU])/256)
|
| 54 |
|
|
|
| 55 |
greg |
1.1 |
#define WHTCOLOR {1.0,1.0,1.0}
|
| 56 |
|
|
#define BLKCOLOR {0.0,0.0,0.0}
|
| 57 |
|
|
#define WHTCOLR {128,128,128,COLXS+1}
|
| 58 |
|
|
#define BLKCOLR {0,0,0,0}
|
| 59 |
greg |
1.2 |
|
| 60 |
greg |
1.3 |
/* definitions for resolution header */
|
| 61 |
greg |
1.2 |
#define XDECR 1
|
| 62 |
|
|
#define YDECR 2
|
| 63 |
|
|
#define YMAJOR 4
|
| 64 |
greg |
1.3 |
|
| 65 |
|
|
extern double ldexp();
|