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 2004-04-20 11:13:11 alanh
28
* add SciTech's GLDirect driver for Windows.
30
* This code is donated to Mesa which allows the usage of
31
* a Direct3D layer (DX7, DX8, DX9 or complete software fallback).
33
* No build system exists for this code yet, that will come.....
35
* Revision 1.1.1.1 1999/08/19 00:55:42 jtg
38
* Revision 1.2 1999/01/03 03:08:57 brianp
41
* Revision 1.1 1999/01/03 03:08:12 brianp
44
* Revision 2.0.2 1997/4/30 15:58:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
45
* Add LUTs need for dithering
50
* Revision 1.1 2004-04-20 11:13:11 alanh
51
* add SciTech's GLDirect driver for Windows.
53
* This code is donated to Mesa which allows the usage of
54
* a Direct3D layer (DX7, DX8, DX9 or complete software fallback).
56
* No build system exists for this code yet, that will come.....
58
* Revision 1.1.1.1 1999/08/19 00:55:42 jtg
61
* Revision 1.2 1999/01/03 03:08:57 brianp
64
* Revision 1.1 1999/01/03 03:08:12 brianp
67
* Revision 2.0.1 1997/4/29 15:52:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
73
* Revision 1.1 2004-04-20 11:13:11 alanh
74
* add SciTech's GLDirect driver for Windows.
76
* This code is donated to Mesa which allows the usage of
77
* a Direct3D layer (DX7, DX8, DX9 or complete software fallback).
79
* No build system exists for this code yet, that will come.....
81
* Revision 1.1.1.1 1999/08/19 00:55:42 jtg
84
* Revision 1.2 1999/01/03 03:08:57 brianp
87
* Revision 1.1 1999/01/03 03:08:12 brianp
90
* Revision 2.0 1996/11/15 10:55:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
93
/* Values for wmesa->pixelformat: */
95
#define PF_8A8B8G8R 3 /* 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */
96
#define PF_8R8G8B 4 /* 32-bit TrueColor: 8-R, 8-G, 8-B */
97
#define PF_5R6G5B 5 /* 16-bit TrueColor: 5-R, 6-G, 5-B bits */
98
#define PF_DITHER8 6 /* Dithered RGB using a lookup table */
99
#define PF_LOOKUP 7 /* Undithered RGB using a lookup table */
100
#define PF_GRAYSCALE 10 /* Grayscale or StaticGray */
101
#define PF_BADFORMAT 11
104
char ColorMap16[] = {
105
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
106
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
107
0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
108
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
109
0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
110
0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,
111
0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
112
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
113
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
114
0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
115
0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,
116
0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,
117
0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,
118
0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,
119
0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,
120
0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
121
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
122
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
123
0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
124
0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
125
0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
126
0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
127
0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,
128
0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
129
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
130
0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
131
0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
132
0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,
133
0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,
134
0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,
135
0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
136
0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F};
138
#define BGR8(r,g,b) (unsigned)(((BYTE)(b & 0xc0 | (g & 0xe0)>>2 | (r & 0xe0)>>5)))
140
#define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(g&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[r])) << 11)))
142
#define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(ColorMap16[g]) << 5)) | (((WORD)(BYTE)(ColorMap16[r])) << 10)))
144
#define BGR24(r,g,b) (unsigned long)(((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16))) << 8)
145
#define BGR32(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
150
* If pixelformat==PF_8A8B8G8R:
152
#define PACK_8A8B8G8R( R, G, B, A ) \
153
( ((A) << 24) | ((B) << 16) | ((G) << 8) | (R) )
157
* If pixelformat==PF_8R8G8B:
159
#define PACK_8R8G8B( R, G, B) ( ((R) << 16) | ((G) << 8) | (B) )
163
* If pixelformat==PF_5R6G5B:
168
#define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(G&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[R])) << 11)))
170
#define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(ColorMap16[G]) << 5)) | (((WORD)(BYTE)(ColorMap16[R])) << 10)))
172
/*----------------------------------------------------------------------------
174
Division lookup tables. These tables compute 0-255 divided by 51 and
175
modulo 51. These tables could approximate gamma correction.
179
char unsigned const aDividedBy51Rounded[256] =
181
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
182
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
183
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
184
1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
185
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
186
2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
187
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
188
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
189
4, 4, 4, 4, 4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 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
212
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
213
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6,
214
7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
215
26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
216
44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
217
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
218
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
219
49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
220
18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
221
36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3,
222
4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
223
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
224
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0,
227
/*----------------------------------------------------------------------------
229
Multiplication LUTs. These compute 0-5 times 6 and 36.
233
char unsigned const aTimes6[6] =
238
char unsigned const aTimes36[6] =
240
0, 36, 72, 108, 144, 180
244
/*----------------------------------------------------------------------------
246
Dither matrices for 8 bit to 2.6 bit halftones.
250
char unsigned const aHalftone16x16[256] =
252
0, 44, 9, 41, 3, 46, 12, 43, 1, 44, 10, 41, 3, 46, 12, 43,
253
34, 16, 25, 19, 37, 18, 28, 21, 35, 16, 26, 19, 37, 18, 28, 21,
254
38, 6, 47, 3, 40, 9, 50, 6, 38, 7, 47, 4, 40, 9, 49, 6,
255
22, 28, 13, 31, 25, 31, 15, 34, 22, 29, 13, 32, 24, 31, 15, 34,
256
2, 46, 12, 43, 1, 45, 10, 42, 2, 45, 11, 42, 1, 45, 11, 42,
257
37, 18, 27, 21, 35, 17, 26, 20, 36, 17, 27, 20, 36, 17, 26, 20,
258
40, 8, 49, 5, 38, 7, 48, 4, 39, 8, 48, 5, 39, 7, 48, 4,
259
24, 30, 15, 33, 23, 29, 13, 32, 23, 30, 14, 33, 23, 29, 14, 32,
260
2, 46, 12, 43, 0, 44, 10, 41, 3, 47, 12, 44, 0, 44, 10, 41,
261
37, 18, 27, 21, 35, 16, 25, 19, 37, 19, 28, 22, 35, 16, 25, 19,
262
40, 9, 49, 5, 38, 7, 47, 4, 40, 9, 50, 6, 38, 6, 47, 3,
263
24, 30, 15, 34, 22, 29, 13, 32, 25, 31, 15, 34, 22, 28, 13, 31,
264
1, 45, 11, 42, 2, 46, 11, 42, 1, 45, 10, 41, 2, 46, 11, 43,
265
36, 17, 26, 20, 36, 17, 27, 21, 35, 16, 26, 20, 36, 18, 27, 21,
266
39, 8, 48, 4, 39, 8, 49, 5, 38, 7, 48, 4, 39, 8, 49, 5,
267
23, 29, 14, 33, 24, 30, 14, 33, 23, 29, 13, 32, 24, 30, 14, 33,
270
char unsigned const aHalftone8x8[64] =
272
0, 38, 9, 47, 2, 40, 11, 50,
273
25, 12, 35, 22, 27, 15, 37, 24,
274
6, 44, 3, 41, 8, 47, 5, 43,
275
31, 19, 28, 15, 34, 21, 31, 18,
276
1, 39, 11, 49, 0, 39, 10, 48,
277
27, 14, 36, 23, 26, 13, 35, 23,
278
7, 46, 4, 43, 7, 45, 3, 42,
279
33, 20, 30, 17, 32, 19, 29, 16,
282
char unsigned const aHalftone4x4_1[16] =
290
char unsigned const aHalftone4x4_2[16] =
298
/***************************************************************************
299
aWinGHalftoneTranslation
301
Translates a 2.6 bit-per-pixel halftoned representation into the
302
slightly rearranged WinG Halftone Palette.
305
char unsigned const aWinGHalftoneTranslation[216] =
b'\\ No newline at end of file'