2362N/A * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A /* Bayer's order-4 dither array. Generated by the code given in 0N/A * Stephen Hawley's article "Ordered Dithering" in Graphics Gems I. 0N/A { 0,
192,
48,
240,
12,
204,
60,
252,
3,
195,
51,
243,
15,
207,
63,
255 },
0N/A {
128,
64,
176,
112,
140,
76,
188,
124,
131,
67,
179,
115,
143,
79,
191,
127 },
0N/A {
32,
224,
16,
208,
44,
236,
28,
220,
35,
227,
19,
211,
47,
239,
31,
223 },
0N/A {
160,
96,
144,
80,
172,
108,
156,
92,
163,
99,
147,
83,
175,
111,
159,
95 },
0N/A {
8,
200,
56,
248,
4,
196,
52,
244,
11,
203,
59,
251,
7,
199,
55,
247 },
0N/A {
136,
72,
184,
120,
132,
68,
180,
116,
139,
75,
187,
123,
135,
71,
183,
119 },
0N/A {
40,
232,
24,
216,
36,
228,
20,
212,
43,
235,
27,
219,
39,
231,
23,
215 },
0N/A {
168,
104,
152,
88,
164,
100,
148,
84,
171,
107,
155,
91,
167,
103,
151,
87 },
0N/A {
2,
194,
50,
242,
14,
206,
62,
254,
1,
193,
49,
241,
13,
205,
61,
253 },
0N/A {
130,
66,
178,
114,
142,
78,
190,
126,
129,
65,
177,
113,
141,
77,
189,
125 },
0N/A {
34,
226,
18,
210,
46,
238,
30,
222,
33,
225,
17,
209,
45,
237,
29,
221 },
0N/A {
162,
98,
146,
82,
174,
110,
158,
94,
161,
97,
145,
81,
173,
109,
157,
93 },
0N/A {
10,
202,
58,
250,
6,
198,
54,
246,
9,
201,
57,
249,
5,
197,
53,
245 },
0N/A {
138,
74,
186,
122,
134,
70,
182,
118,
137,
73,
185,
121,
133,
69,
181,
117 },
0N/A {
42,
234,
26,
218,
38,
230,
22,
214,
41,
233,
25,
217,
37,
229,
21,
213 },
0N/A {
170,
106,
154,
90,
166,
102,
150,
86,
169,
105,
153,
89,
165,
101,
149,
85 }
0N/A// FIXME: tinting on some colormaps (e.g. 1-2-1) means something is slightly wrong with 0N/A// colormap calculation... probably it's some rounding error 0N/A/* calculates the colorTable for mapping from 0..255 to 0..numColors-1 0N/A also calculates the dithering matrix, scaling baseDitherMatrix accordingly */ 0N/A/* scale a number on the range of 0..numColorsIn-1 to 0..numColorsOut-1 0N/A 0 maps to 0 and numColorsIn-1 maps to numColorsOut-1 0N/A intermediate values are spread evenly between 0 and numColorsOut-1 */ 0N/A/* build a colormap for a color cube and a dithering matrix. color cube is quantized 0N/A according to the provided maximum number of colors */ 0N/A // static const int scale[3]={10000/11,10000/69,10000/30}; 0N/A // FIXME: sort out the adaptive color cube subdivision... realistic 11:69:30 is good on photos, 0N/A // but would be bad on other pictures. A stupid approximation is used now. 0N/A static const int scale[
3] = {
8,
4,
6 };
0N/A // maxNumColors should be at least 2x2x2=8, or we lose some color components completely 0N/A /* bubble sort the three indexes according to scaled numColors values */ 0N/A /* try increasing numColors for the first color */ 0N/A the function below is a line conversion loop 0N/A incSrc and incDst are pSrc and pDst increment values for the loop, in bytes 0N/A mode defines how the pixels should be processed 0N/A mode==CVT_COPY means the pixels should be copied as is 0N/A mode==CVT_ALPHATEST means pixels should be skipped when source pixel alpha is above the threshold 0N/A mode==CVT_BLEND means alpha blending between source and destination should be performed, while 0N/A destination alpha should be retained. source alpha is used for blending. 0N/A/* initialize ImageRect structure according to function arguments */ 0N/A/* copy image rectangle from source to destination, or from two sources with blending */ 0N/A/* init the masks; all other parameters are initialized to default values */ 0N/A for (i = 0; i <
4; i++) {
0N/A/* dump the visual format */ 0N/A printf(
"byteorder=%d colormap=%08x depthBytes=%d fixedBits=%08x transparentColor=%u ",
0N/A for (i = 0; i <
4; i++) {
0N/A/* optimize the format */ 0N/A /* FIXME: some advanced optimizations are possible, especially for format pairs */