7070b85e3254afac14d29f45120395efbe141846
1 /* File name : colors.h
4 * Header file for display driver for Mesa 2.3 under
5 * Windows95 and WindowsNT
6 * This file defines macros and global variables needed
7 * for converting color format
9 * Copyright (C) 1996- Li Wei
10 * Address : Institute of Artificial Intelligence
12 * : Xi'an Jiaotong University
13 * Email : liwei@aiar.xjtu.edu.cn
14 * Web page : http://sun.aiar.xjtu.edu.cn
16 * This file and its associations are partially based on the
17 * Windows NT driver for Mesa, written by Mark Leaming
21 /* $Log: ddcolors.h 1997/6/14 by Li Wei(liwei@aiar.xjtu.edu.cn)
22 * Macros for pixel format defined
27 * Revision 1.1 2003/07/24 03:47:46 kschultz
28 * Source code for GDI driver.
30 * Revision 1.3 2002/01/15 18:14:34 kschultz
31 * Fixed pixel color component problem and clear code for 24-bit Windows
32 * devices. (Jeff Lewis)
34 * Revision 1.2 2002/01/15 18:11:36 kschultz
35 * Remove trailing CR's. No logical changes.
37 * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
40 * Revision 1.2 1999/01/03 03:08:57 brianp
43 * Revision 1.1 1999/01/03 03:08:12 brianp
46 * Revision 2.0.2 1997/4/30 15:58:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
47 * Add LUTs need for dithering
52 * Revision 1.1 2003/07/24 03:47:46 kschultz
53 * Source code for GDI driver.
55 * Revision 1.3 2002/01/15 18:14:34 kschultz
56 * Fixed pixel color component problem and clear code for 24-bit Windows
57 * devices. (Jeff Lewis)
59 * Revision 1.2 2002/01/15 18:11:36 kschultz
60 * Remove trailing CR's. No logical changes.
62 * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
65 * Revision 1.2 1999/01/03 03:08:57 brianp
68 * Revision 1.1 1999/01/03 03:08:12 brianp
71 * Revision 2.0.1 1997/4/29 15:52:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
77 * Revision 1.1 2003/07/24 03:47:46 kschultz
78 * Source code for GDI driver.
80 * Revision 1.3 2002/01/15 18:14:34 kschultz
81 * Fixed pixel color component problem and clear code for 24-bit Windows
82 * devices. (Jeff Lewis)
84 * Revision 1.2 2002/01/15 18:11:36 kschultz
85 * Remove trailing CR's. No logical changes.
87 * Revision 1.1.1.1 1999/08/19 00:55:42 jtg
90 * Revision 1.2 1999/01/03 03:08:57 brianp
93 * Revision 1.1 1999/01/03 03:08:12 brianp
96 * Revision 2.0 1996/11/15 10:55:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
99 /* Values for wmesa->pixelformat: */
101 #define PF_8A8B8G8R 3 /* 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */
102 #define PF_8R8G8B 4 /* 32-bit TrueColor: 8-R, 8-G, 8-B */
103 #define PF_5R6G5B 5 /* 16-bit TrueColor: 5-R, 6-G, 5-B bits */
104 #define PF_DITHER8 6 /* Dithered RGB using a lookup table */
105 #define PF_LOOKUP 7 /* Undithered RGB using a lookup table */
106 #define PF_GRAYSCALE 10 /* Grayscale or StaticGray */
107 #define PF_BADFORMAT 11
110 char ColorMap16
[] = {
111 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
112 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
113 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
114 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
115 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
116 0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,
117 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
118 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
119 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
120 0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
121 0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,
122 0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,
123 0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,
124 0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,
125 0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,
126 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
127 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
128 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
129 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
130 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
131 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
132 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
133 0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,
134 0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
135 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
136 0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
137 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
138 0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,
139 0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,
140 0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,
141 0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
142 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F};
144 #define BGR8(r,g,b) (unsigned)(((BYTE)(b & 0xc0 | (g & 0xe0)>>2 | (r & 0xe0)>>5)))
146 #define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(g&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[r])) << 11)))
148 #define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(ColorMap16[g]) << 5)) | (((WORD)(BYTE)(ColorMap16[r])) << 10)))
150 #define BGR24(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
152 #define BGR32(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
157 * If pixelformat==PF_8A8B8G8R:
159 #define PACK_8A8B8G8R( R, G, B, A ) \
160 ( ((A) << 24) | ((B) << 16) | ((G) << 8) | (R) )
164 * If pixelformat==PF_8R8G8B:
166 #define PACK_8R8G8B( R, G, B) ( ((R) << 16) | ((G) << 8) | (B) )
170 * If pixelformat==PF_5R6G5B:
175 #define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(G&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[R])) << 11)))
177 #define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(ColorMap16[G]) << 5)) | (((WORD)(BYTE)(ColorMap16[R])) << 10)))
179 /*----------------------------------------------------------------------------
181 Division lookup tables. These tables compute 0-255 divided by 51 and
182 modulo 51. These tables could approximate gamma correction.
186 char unsigned const aDividedBy51Rounded
[256] =
188 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
189 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
190 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
191 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
192 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
193 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
194 3, 3, 3, 3, 3, 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4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
213 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
216 char unsigned const aModulo51
[256] =
218 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
219 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
220 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6,
221 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
222 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
223 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
224 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
225 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
226 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
227 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
228 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3,
229 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
230 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
231 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0,
234 /*----------------------------------------------------------------------------
236 Multiplication LUTs. These compute 0-5 times 6 and 36.
240 char unsigned const aTimes6
[6] =
245 char unsigned const aTimes36
[6] =
247 0, 36, 72, 108, 144, 180
251 /*----------------------------------------------------------------------------
253 Dither matrices for 8 bit to 2.6 bit halftones.
257 char unsigned const aHalftone16x16
[256] =
259 0, 44, 9, 41, 3, 46, 12, 43, 1, 44, 10, 41, 3, 46, 12, 43,
260 34, 16, 25, 19, 37, 18, 28, 21, 35, 16, 26, 19, 37, 18, 28, 21,
261 38, 6, 47, 3, 40, 9, 50, 6, 38, 7, 47, 4, 40, 9, 49, 6,
262 22, 28, 13, 31, 25, 31, 15, 34, 22, 29, 13, 32, 24, 31, 15, 34,
263 2, 46, 12, 43, 1, 45, 10, 42, 2, 45, 11, 42, 1, 45, 11, 42,
264 37, 18, 27, 21, 35, 17, 26, 20, 36, 17, 27, 20, 36, 17, 26, 20,
265 40, 8, 49, 5, 38, 7, 48, 4, 39, 8, 48, 5, 39, 7, 48, 4,
266 24, 30, 15, 33, 23, 29, 13, 32, 23, 30, 14, 33, 23, 29, 14, 32,
267 2, 46, 12, 43, 0, 44, 10, 41, 3, 47, 12, 44, 0, 44, 10, 41,
268 37, 18, 27, 21, 35, 16, 25, 19, 37, 19, 28, 22, 35, 16, 25, 19,
269 40, 9, 49, 5, 38, 7, 47, 4, 40, 9, 50, 6, 38, 6, 47, 3,
270 24, 30, 15, 34, 22, 29, 13, 32, 25, 31, 15, 34, 22, 28, 13, 31,
271 1, 45, 11, 42, 2, 46, 11, 42, 1, 45, 10, 41, 2, 46, 11, 43,
272 36, 17, 26, 20, 36, 17, 27, 21, 35, 16, 26, 20, 36, 18, 27, 21,
273 39, 8, 48, 4, 39, 8, 49, 5, 38, 7, 48, 4, 39, 8, 49, 5,
274 23, 29, 14, 33, 24, 30, 14, 33, 23, 29, 13, 32, 24, 30, 14, 33,
277 char unsigned const aHalftone8x8
[64] =
279 0, 38, 9, 47, 2, 40, 11, 50,
280 25, 12, 35, 22, 27, 15, 37, 24,
281 6, 44, 3, 41, 8, 47, 5, 43,
282 31, 19, 28, 15, 34, 21, 31, 18,
283 1, 39, 11, 49, 0, 39, 10, 48,
284 27, 14, 36, 23, 26, 13, 35, 23,
285 7, 46, 4, 43, 7, 45, 3, 42,
286 33, 20, 30, 17, 32, 19, 29, 16,
289 char unsigned const aHalftone4x4_1
[16] =
297 char unsigned const aHalftone4x4_2
[16] =
305 /***************************************************************************
306 aWinGHalftoneTranslation
308 Translates a 2.6 bit-per-pixel halftoned representation into the
309 slightly rearranged WinG Halftone Palette.
312 char unsigned const aWinGHalftoneTranslation
[216] =