xref: /plan9/sys/src/cmd/gs/src/gxcvalue.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1995, 1996 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: gxcvalue.h,v 1.4 2002/02/21 22:24:53 giles Exp $ */
18 /* Definition of device color values */
19 
20 #ifndef gxcvalue_INCLUDED
21 #  define gxcvalue_INCLUDED
22 
23 /* Define the type for gray or RGB values at the driver interface. */
24 typedef unsigned short gx_color_value;
25 
26 #define arch_sizeof_gx_color_value arch_sizeof_short
27 /* We might use less than the full range someday. */
28 /* ...bits must lie between 8 and 16. */
29 #define gx_color_value_bits (sizeof(gx_color_value) * 8)
30 #define gx_max_color_value ((gx_color_value)((1L << gx_color_value_bits) - 1))
31 #define gx_color_value_to_byte(cv)\
32   ((cv) >> (gx_color_value_bits - 8))
33 #define gx_color_value_from_byte(cb)\
34   (((cb) << (gx_color_value_bits - 8)) + ((cb) >> (16 - gx_color_value_bits)))
35 
36 /* Convert between gx_color_values and fracs. */
37 #define frac2cv(fr) frac2ushort(fr)
38 #define cv2frac(cv) ushort2frac(cv)
39 
40 #endif /* gxcvalue_INCLUDED */
41