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 1999/08/19 00:55:42 jtg
30 * Revision 1.2 1999/01/03 03:08:57 brianp
33 * Revision 1.1 1999/01/03 03:08:12 brianp
36 * Revision 2.0.2 1997/4/30 15:58:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
37 * Add LUTs need for dithering
42 * Revision 1.1 1999/08/19 00:55:42 jtg
45 * Revision 1.2 1999/01/03 03:08:57 brianp
48 * Revision 1.1 1999/01/03 03:08:12 brianp
51 * Revision 2.0.1 1997/4/29 15:52:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
57 * Revision 1.1 1999/08/19 00:55:42 jtg
60 * Revision 1.2 1999/01/03 03:08:57 brianp
63 * Revision 1.1 1999/01/03 03:08:12 brianp
66 * Revision 2.0 1996/11/15 10:55:00 CST by Li Wei(liwei@aiar.xjtu.edu.cn)
69 /* Values for wmesa->pixelformat: */
71 #define PF_8A8B8G8R 3 /* 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */
72 #define PF_8R8G8B 4 /* 32-bit TrueColor: 8-R, 8-G, 8-B */
73 #define PF_5R6G5B 5 /* 16-bit TrueColor: 5-R, 6-G, 5-B bits */
74 #define PF_DITHER8 6 /* Dithered RGB using a lookup table */
75 #define PF_LOOKUP 7 /* Undithered RGB using a lookup table */
76 #define PF_GRAYSCALE 10 /* Grayscale or StaticGray */
77 #define PF_BADFORMAT 11
81 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
82 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
83 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
84 0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
85 0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,
86 0x05,0x05,0x05,0x05,0x05,0x05,0x05,0x05,
87 0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,
88 0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
89 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
90 0x09,0x09,0x09,0x09,0x09,0x09,0x09,0x09,
91 0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,
92 0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,0x0B,
93 0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,0x0C,
94 0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,0x0D,
95 0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,0x0E,
96 0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,
97 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
98 0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
99 0x12,0x12,0x12,0x12,0x12,0x12,0x12,0x12,
100 0x13,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
101 0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14,
102 0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
103 0x16,0x16,0x16,0x16,0x16,0x16,0x16,0x16,
104 0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,
105 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
106 0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
107 0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,0x1A,
108 0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,0x1B,
109 0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,
110 0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,0x1D,
111 0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,
112 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F};
114 #define BGR8(r,g,b) (unsigned)(((BYTE)(b & 0xc0 | (g & 0xe0)>>2 | (r & 0xe0)>>5)))
116 #define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(g&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[r])) << 11)))
118 #define BGR16(r,g,b) ((WORD)(((BYTE)(ColorMap16[b]) | ((BYTE)(ColorMap16[g]) << 5)) | (((WORD)(BYTE)(ColorMap16[r])) << 10)))
120 #define BGR24(r,g,b) (unsigned long)(((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16))) << 8)
121 #define BGR32(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(r))<<16)))
126 * If pixelformat==PF_8A8B8G8R:
128 #define PACK_8A8B8G8R( R, G, B, A ) \
129 ( ((A) << 24) | ((B) << 16) | ((G) << 8) | (R) )
133 * If pixelformat==PF_8R8G8B:
135 #define PACK_8R8G8B( R, G, B) ( ((R) << 16) | ((G) << 8) | (B) )
139 * If pixelformat==PF_5R6G5B:
144 #define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(G&0xfc) << 3)) | (((WORD)(BYTE)(ColorMap16[R])) << 11)))
146 #define PACK_5R6G5B( R, G, B) ((WORD)(((BYTE)(ColorMap16[B]) | ((BYTE)(ColorMap16[G]) << 5)) | (((WORD)(BYTE)(ColorMap16[R])) << 10)))
148 /*----------------------------------------------------------------------------
150 Division lookup tables. These tables compute 0-255 divided by 51 and
151 modulo 51. These tables could approximate gamma correction.
155 char un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1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
175 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
176 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
177 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
178 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
179 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
180 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
181 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
182 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5,
185 char unsigned const aModulo51
[256] =
187 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
188 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
189 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6,
190 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
191 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
192 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
193 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
194 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
195 49, 50, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
196 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
197 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 1, 2, 3,
198 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
199 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
200 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0,
203 /*----------------------------------------------------------------------------
205 Multiplication LUTs. These compute 0-5 times 6 and 36.
209 char unsigned const aTimes6
[6] =
214 char unsigned const aTimes36
[6] =
216 0, 36, 72, 108, 144, 180
220 /*----------------------------------------------------------------------------
222 Dither matrices for 8 bit to 2.6 bit halftones.
226 char unsigned const aHalftone16x16
[256] =
228 0, 44, 9, 41, 3, 46, 12, 43, 1, 44, 10, 41, 3, 46, 12, 43,
229 34, 16, 25, 19, 37, 18, 28, 21, 35, 16, 26, 19, 37, 18, 28, 21,
230 38, 6, 47, 3, 40, 9, 50, 6, 38, 7, 47, 4, 40, 9, 49, 6,
231 22, 28, 13, 31, 25, 31, 15, 34, 22, 29, 13, 32, 24, 31, 15, 34,
232 2, 46, 12, 43, 1, 45, 10, 42, 2, 45, 11, 42, 1, 45, 11, 42,
233 37, 18, 27, 21, 35, 17, 26, 20, 36, 17, 27, 20, 36, 17, 26, 20,
234 40, 8, 49, 5, 38, 7, 48, 4, 39, 8, 48, 5, 39, 7, 48, 4,
235 24, 30, 15, 33, 23, 29, 13, 32, 23, 30, 14, 33, 23, 29, 14, 32,
236 2, 46, 12, 43, 0, 44, 10, 41, 3, 47, 12, 44, 0, 44, 10, 41,
237 37, 18, 27, 21, 35, 16, 25, 19, 37, 19, 28, 22, 35, 16, 25, 19,
238 40, 9, 49, 5, 38, 7, 47, 4, 40, 9, 50, 6, 38, 6, 47, 3,
239 24, 30, 15, 34, 22, 29, 13, 32, 25, 31, 15, 34, 22, 28, 13, 31,
240 1, 45, 11, 42, 2, 46, 11, 42, 1, 45, 10, 41, 2, 46, 11, 43,
241 36, 17, 26, 20, 36, 17, 27, 21, 35, 16, 26, 20, 36, 18, 27, 21,
242 39, 8, 48, 4, 39, 8, 49, 5, 38, 7, 48, 4, 39, 8, 49, 5,
243 23, 29, 14, 33, 24, 30, 14, 33, 23, 29, 13, 32, 24, 30, 14, 33,
246 char unsigned const aHalftone8x8
[64] =
248 0, 38, 9, 47, 2, 40, 11, 50,
249 25, 12, 35, 22, 27, 15, 37, 24,
250 6, 44, 3, 41, 8, 47, 5, 43,
251 31, 19, 28, 15, 34, 21, 31, 18,
252 1, 39, 11, 49, 0, 39, 10, 48,
253 27, 14, 36, 23, 26, 13, 35, 23,
254 7, 46, 4, 43, 7, 45, 3, 42,
255 33, 20, 30, 17, 32, 19, 29, 16,
258 char unsigned const aHalftone4x4_1
[16] =
266 char unsigned const aHalftone4x4_2
[16] =
274 /***************************************************************************
275 aWinGHalftoneTranslation
277 Translates a 2.6 bit-per-pixel halftoned representation into the
278 slightly rearranged WinG Halftone Palette.
281 char unsigned const aWinGHalftoneTranslation
[216] =