1 | /* ------------------ */ |
---|
2 | /* --- ppalette.c --- */ |
---|
3 | /* ------------------ */ |
---|
4 | |
---|
5 | // Copyright (c) 2013-2014 Lionel Lacassagne, All Rights Reserved |
---|
6 | // Laboratoire de Recherche en Informatique |
---|
7 | // Universite Paris-Sud / CNRS |
---|
8 | |
---|
9 | // ajout des demi-palettes n-colors + gray |
---|
10 | // PackGrayLower PackGrayUpper |
---|
11 | |
---|
12 | |
---|
13 | #include <stdio.h> |
---|
14 | #include <stdlib.h> |
---|
15 | #include <math.h> |
---|
16 | |
---|
17 | |
---|
18 | #ifdef CLI |
---|
19 | #include "nrc_os_config.h" |
---|
20 | #include "nrc.h" |
---|
21 | #endif |
---|
22 | |
---|
23 | #include "palette.h" |
---|
24 | |
---|
25 | /* |
---|
26 | * Modif : 98-11-18 ajout de Save |
---|
27 | */ |
---|
28 | |
---|
29 | /* ---------------------------------------------- */ |
---|
30 | IMAGE_EXPORT(void) Palette_Display(RGBQuad *palette) |
---|
31 | /* ---------------------------------------------- */ |
---|
32 | { |
---|
33 | int i; |
---|
34 | printf("Palette"); |
---|
35 | for (i = 0; i < 256; i++) { |
---|
36 | printf("%4d:%4d%4d%4d\n", i,palette[i].red, palette[i].green, palette[i].blue); |
---|
37 | } |
---|
38 | } |
---|
39 | /* ----------------------------------------------------------- */ |
---|
40 | //IMAGE_EXPORT(void) Palette_Save(RGBQuad *palette, char *filename) |
---|
41 | /* ----------------------------------------------------------- */ |
---|
42 | /*{ |
---|
43 | int i, j; |
---|
44 | int k = 32; |
---|
45 | int hauteur = k, largeur = k*256; |
---|
46 | uint8 **X; |
---|
47 | Image *image; |
---|
48 | |
---|
49 | |
---|
50 | IConstructor(&image, hauteur, largeur, 0); |
---|
51 | X = (uint8**) Image_Get_Data(image); |
---|
52 | for(i=0; i<hauteur; i++) { |
---|
53 | for(j=0; j<largeur; j++) { |
---|
54 | X[i][j] = j/k; |
---|
55 | } |
---|
56 | } |
---|
57 | //SaveBMP(image, palette, filename); |
---|
58 | IDestructor(&image); |
---|
59 | }*/ |
---|
60 | /* --------------------------------------------------------------------- */ |
---|
61 | //IMAGE_EXPORT(void) Palette_SaveSub(RGBQuad *palette, int n, char *filename) |
---|
62 | /* --------------------------------------------------------------------- */ |
---|
63 | /*{ |
---|
64 | int i, j; |
---|
65 | int hauteur = 8, largeur = 8*n; |
---|
66 | uint8 **X; |
---|
67 | Image *image; |
---|
68 | |
---|
69 | |
---|
70 | IConstructor(&image, largeur, hauteur, 0); |
---|
71 | X = (uint8**) Image_Get_Data(image); |
---|
72 | for(i=0; i<hauteur; i++) { |
---|
73 | for(j=8; j<=largeur; j++) { |
---|
74 | X[i][j] = j/8; |
---|
75 | } |
---|
76 | } |
---|
77 | //SaveBMP(image, palette, filename); |
---|
78 | IDestructor(&image); |
---|
79 | }*/ |
---|
80 | /* --------------------------------------------------- */ |
---|
81 | IMAGE_EXPORT(void) Palette_GrayBlue2Red(RGBQuad *palette) |
---|
82 | /* --------------------------------------------------- */ |
---|
83 | /* ancien SetupPalette */ |
---|
84 | { |
---|
85 | int i; |
---|
86 | |
---|
87 | /* |
---|
88 | * Partie basse : image en niveau de gris |
---|
89 | */ |
---|
90 | for(i=0; i<128; i++) { |
---|
91 | palette[i].blue = 2*i; |
---|
92 | palette[i].green = 2*i; |
---|
93 | palette[i].red = 2*i; |
---|
94 | palette[i].reserved = 0; |
---|
95 | } |
---|
96 | /* |
---|
97 | * Partie haute : couleurs additionnelles |
---|
98 | * degrade de bleus puis degrade de rouges |
---|
99 | */ |
---|
100 | for(i=0; i<128; i++) { |
---|
101 | palette[i+128].blue = 255 - 2*i; |
---|
102 | palette[i+128].green = 0; |
---|
103 | palette[i+128].red = 2*i+1; |
---|
104 | palette[i+128].reserved = 0; |
---|
105 | } |
---|
106 | palette[128].blue = 255; |
---|
107 | palette[128].green = 0; |
---|
108 | palette[128].red = 0; |
---|
109 | palette[128].reserved = 0; |
---|
110 | |
---|
111 | palette[255].blue = 0; |
---|
112 | palette[255].green = 0; |
---|
113 | palette[255].red = 255; |
---|
114 | palette[255].reserved = 0; |
---|
115 | |
---|
116 | /*for(i=0; i<256; i++) { |
---|
117 | palette[i].rgbBlue = i; |
---|
118 | palette[i].rgbGreen = i; |
---|
119 | palette[i].rgbRed = i; |
---|
120 | palette[i].rgbReserved = 0; |
---|
121 | }*/ |
---|
122 | |
---|
123 | /*if(verbose) { |
---|
124 | for(i=0; i<256; i++) { |
---|
125 | printf("%d %3d %3d %3d\n", i, Palette[i].rgbRed, Palette[i].rgbGreen, Palette[i].rgbBlue); |
---|
126 | } |
---|
127 | }*/ |
---|
128 | } |
---|
129 | /* ---------------------------------------------- */ |
---|
130 | IMAGE_EXPORT(void) Palette_Classic(RGBQuad *palette) |
---|
131 | /* ---------------------------------------------- */ |
---|
132 | { |
---|
133 | int i; |
---|
134 | |
---|
135 | for(i=0; i<256; i++) { |
---|
136 | palette[i].blue = (uint8) i; |
---|
137 | palette[i].green = (uint8) i; |
---|
138 | palette[i].red = (uint8) i; |
---|
139 | palette[i].reserved = (uint8) 0; |
---|
140 | } |
---|
141 | } |
---|
142 | /* ------------------------------------------- */ |
---|
143 | IMAGE_EXPORT(void) Palette_Gray(RGBQuad *palette) |
---|
144 | /* ------------------------------------------- */ |
---|
145 | { |
---|
146 | int i; |
---|
147 | |
---|
148 | for(i=0; i<256; i++) { |
---|
149 | palette[i].blue = (uint8) i; |
---|
150 | palette[i].green = (uint8) i; |
---|
151 | palette[i].red = (uint8) i; |
---|
152 | palette[i].reserved = (uint8) 0; |
---|
153 | } |
---|
154 | } |
---|
155 | |
---|
156 | /* ---------------------------------------------- */ |
---|
157 | IMAGE_EXPORT(void) Palette_Pseudo1(RGBQuad *palette) |
---|
158 | /* ---------------------------------------------- */ |
---|
159 | { |
---|
160 | int i; |
---|
161 | for(i=0; i<255; i++) { |
---|
162 | palette[i].blue = (uint8) ((3*i)%256); |
---|
163 | palette[i].green = (uint8) ((87*i)%256); |
---|
164 | palette[i].red = (uint8) ((117*i)%256); |
---|
165 | palette[i].reserved = 0; |
---|
166 | } |
---|
167 | palette[255].blue = (uint8) 255; |
---|
168 | palette[255].green = (uint8) 255; |
---|
169 | palette[255].red = (uint8) 255; |
---|
170 | palette[255].reserved = (uint8) 0; |
---|
171 | } |
---|
172 | /* ---------------------------------------------- */ |
---|
173 | IMAGE_EXPORT(void) Palette_Pseudo2(RGBQuad *palette) |
---|
174 | /* ---------------------------------------------- */ |
---|
175 | { |
---|
176 | int i; |
---|
177 | for(i=0; i<255; i++) { |
---|
178 | palette[i].blue = (uint8) (( 257*i)%256); /* nextprime(256) */ |
---|
179 | palette[i].green = (uint8) (( 65537*i)%256); /* nextprime(256^2) */ |
---|
180 | palette[i].red = (uint8) ((16777259*i)%256); /* nextprime(256^3) */ |
---|
181 | palette[i].reserved = 0; |
---|
182 | } |
---|
183 | palette[255].blue = (uint8) 255; |
---|
184 | palette[255].green = (uint8) 255; |
---|
185 | palette[255].red = (uint8) 255; |
---|
186 | palette[255].reserved = (uint8) 0; |
---|
187 | } |
---|
188 | /* ------------------------------------------ */ |
---|
189 | IMAGE_EXPORT(void) Palette_Hue(RGBQuad *palette) |
---|
190 | /* ------------------------------------------ */ |
---|
191 | { |
---|
192 | int i; |
---|
193 | double k, r, g, b; /* alpha rgb */ |
---|
194 | for(i=0; i<255; i++) { |
---|
195 | |
---|
196 | k = (double) i / 256; |
---|
197 | |
---|
198 | r = 2.0 * k * PI; |
---|
199 | g = 2.0 * k * PI - (2.0*PI/3.0); |
---|
200 | b = 2.0 * k * PI - (4.0*PI/3.0); |
---|
201 | |
---|
202 | palette[i].blue = (uint8) (128.0 * (1.0 + cos(b))); |
---|
203 | palette[i].green = (uint8) (128.0 * (1.0 + cos(g))); |
---|
204 | palette[i].red = (uint8) (128.0 * (1.0 + cos(r))); |
---|
205 | palette[i].reserved = 0; |
---|
206 | } |
---|
207 | } |
---|
208 | /* ------------------------------------------------ */ |
---|
209 | IMAGE_EXPORT(void) Palette_RandomHue(RGBQuad *palette) |
---|
210 | /* ------------------------------------------------ */ |
---|
211 | { |
---|
212 | int i, ii; |
---|
213 | double k, r, g, b; /* alpha rgb */ |
---|
214 | for(i=0; i<255; i++) { |
---|
215 | |
---|
216 | ii = (3*i)%256; |
---|
217 | k = (double) (ii / 256); |
---|
218 | |
---|
219 | r = 2.0 * k * PI; |
---|
220 | g = 2.0 * k * PI - (2.0*PI/3.0); |
---|
221 | b = 2.0 * k * PI - (4.0*PI/3.0); |
---|
222 | |
---|
223 | palette[i].blue = (uint8) (128.0 * (1.0 + cos(b))); |
---|
224 | palette[i].green = (uint8) (128.0 * (1.0 + cos(g))); |
---|
225 | palette[i].red = (uint8) (128.0 * (1.0 + cos(r))); |
---|
226 | palette[i].reserved = 0; |
---|
227 | } |
---|
228 | } |
---|
229 | /* -------------------------------------------- */ |
---|
230 | IMAGE_EXPORT(void) Palette_HueBW(RGBQuad *palette) |
---|
231 | /* -------------------------------------------- */ |
---|
232 | { |
---|
233 | int i; |
---|
234 | double k, r, g, b; /* alpha rgb */ |
---|
235 | for(i=0; i<255; i++) { |
---|
236 | |
---|
237 | k = (double) i / 256; |
---|
238 | |
---|
239 | r = 2.0 * k * PI; |
---|
240 | g = 2.0 * k * PI - (2.0*PI/3.0); |
---|
241 | b = 2.0 * k * PI - (4.0*PI/3.0); |
---|
242 | |
---|
243 | palette[i].blue = (uint8) (128.0 * (1.0 + cos(b))); |
---|
244 | palette[i].green = (uint8) (128.0 * (1.0 + cos(g))); |
---|
245 | palette[i].red = (uint8) (128.0 * (1.0 + cos(r))); |
---|
246 | palette[i].reserved = 0; |
---|
247 | } |
---|
248 | palette[0].blue = (uint8) 0; |
---|
249 | palette[0].green = (uint8) 0; |
---|
250 | palette[0].red = (uint8) 0; |
---|
251 | palette[0].reserved = (uint8) 0; |
---|
252 | |
---|
253 | palette[255].blue = (uint8) 255; |
---|
254 | palette[255].green = (uint8) 255; |
---|
255 | palette[255].red = (uint8) 255; |
---|
256 | palette[255].reserved = (uint8) 0; |
---|
257 | } |
---|
258 | /* -------------------------------------------------- */ |
---|
259 | IMAGE_EXPORT(void) Palette_RandomHueBW(RGBQuad *palette) |
---|
260 | /* -------------------------------------------------- */ |
---|
261 | { |
---|
262 | int i, ii, im; |
---|
263 | double k, r, g, b; /* alpha rgb */ |
---|
264 | for(i=0; i<255; i++) { |
---|
265 | |
---|
266 | ii = (7*i)%256; |
---|
267 | k = (double) ii / 256; |
---|
268 | |
---|
269 | r = 2.0 * k * PI; |
---|
270 | g = 2.0 * k * PI - (2.0*PI/3.0); |
---|
271 | b = 2.0 * k * PI - (4.0*PI/3.0); |
---|
272 | |
---|
273 | im = (i-27)%255; |
---|
274 | im = i; |
---|
275 | palette[im].blue = (uint8) (128.0 * (1.0 + cos(b))); |
---|
276 | palette[im].green = (uint8) (128.0 * (1.0 + cos(g))); |
---|
277 | palette[im].red = (uint8) (128.0 * (1.0 + cos(r))); |
---|
278 | palette[im].reserved = 0; |
---|
279 | } |
---|
280 | palette[0].blue = (uint8) 0; |
---|
281 | palette[0].green = (uint8) 0; |
---|
282 | palette[0].red = (uint8) 0; |
---|
283 | palette[0].reserved = (uint8) 0; |
---|
284 | |
---|
285 | palette[255].blue = (uint8) 255; |
---|
286 | palette[255].green = (uint8) 255; |
---|
287 | palette[255].red = (uint8) 255; |
---|
288 | palette[255].reserved = (uint8) 0; |
---|
289 | } |
---|
290 | /* ------------------------------------------------ */ |
---|
291 | IMAGE_EXPORT(void) Palette_3ColorsBW(RGBQuad *palette) |
---|
292 | /* ------------------------------------------------ */ |
---|
293 | { |
---|
294 | int i; |
---|
295 | uint8 rr = 255,gg = 255, bb = 255; |
---|
296 | RGBQuad pattern[3]; |
---|
297 | |
---|
298 | pattern[0].red = rr; |
---|
299 | pattern[0].green = 0; |
---|
300 | pattern[0].blue = 0; |
---|
301 | |
---|
302 | pattern[1].red = 0; |
---|
303 | pattern[1].green = gg; |
---|
304 | pattern[1].blue = 0; |
---|
305 | |
---|
306 | pattern[2].red = 0; |
---|
307 | pattern[2].green = 0; |
---|
308 | pattern[2].blue = bb; |
---|
309 | |
---|
310 | for(i=0; i<255; i++) { |
---|
311 | palette[1+i].red = pattern[i%3].red; |
---|
312 | palette[1+i].green = pattern[i%3].green; |
---|
313 | palette[1+i].blue = pattern[i%3].blue; |
---|
314 | palette[1+i].reserved = (uint8) 0; |
---|
315 | } |
---|
316 | palette[0].blue = (uint8) 0; |
---|
317 | palette[0].green = (uint8) 0; |
---|
318 | palette[0].red = (uint8) 0; |
---|
319 | palette[0].reserved = (uint8) 0; |
---|
320 | |
---|
321 | palette[255].blue = (uint8) 255; |
---|
322 | palette[255].green = (uint8) 255; |
---|
323 | palette[255].red = (uint8) 255; |
---|
324 | palette[255].reserved = (uint8) 0; |
---|
325 | } |
---|
326 | /* ---------------------------------------------- */ |
---|
327 | IMAGE_EXPORT(void) Palette_3Colors(RGBQuad *palette) |
---|
328 | /* ---------------------------------------------- */ |
---|
329 | { |
---|
330 | int i; |
---|
331 | uint8 rr = 255,gg = 255, bb = 255; |
---|
332 | RGBQuad pattern[3]; |
---|
333 | |
---|
334 | pattern[0].red = rr; |
---|
335 | pattern[0].green = 0; |
---|
336 | pattern[0].blue = 0; |
---|
337 | |
---|
338 | pattern[1].red = 0; |
---|
339 | pattern[1].green = gg; |
---|
340 | pattern[1].blue = 0; |
---|
341 | |
---|
342 | pattern[2].red = 0; |
---|
343 | pattern[2].green = 0; |
---|
344 | pattern[2].blue = bb; |
---|
345 | |
---|
346 | for(i=0; i<256; i++) { |
---|
347 | palette[i].red = pattern[i%3].red; |
---|
348 | palette[i].green = pattern[i%3].green; |
---|
349 | palette[i].blue = pattern[i%3].blue; |
---|
350 | palette[i].reserved = (uint8) 0; |
---|
351 | } |
---|
352 | } |
---|
353 | /* -------------------------------------------------- */ |
---|
354 | IMAGE_EXPORT(void) Palette_3Colors_Red(RGBQuad *palette) |
---|
355 | /* -------------------------------------------------- */ |
---|
356 | { |
---|
357 | int i; |
---|
358 | uint8 rr = 255,gg = 255, bb = 255; |
---|
359 | RGBQuad pattern[3]; |
---|
360 | |
---|
361 | pattern[0].red = rr; |
---|
362 | pattern[0].green = 0; |
---|
363 | pattern[0].blue = 0; |
---|
364 | |
---|
365 | pattern[1].red = 0; |
---|
366 | pattern[1].green = gg; |
---|
367 | pattern[1].blue = 0; |
---|
368 | |
---|
369 | pattern[2].red = 0; |
---|
370 | pattern[2].green = 0; |
---|
371 | pattern[2].blue = bb; |
---|
372 | |
---|
373 | /* rouge en 0 */ |
---|
374 | palette[0].red = pattern[0].red; |
---|
375 | palette[0].green = pattern[0].green; |
---|
376 | palette[0].blue = pattern[0].blue; |
---|
377 | |
---|
378 | for(i=0; i<255; i++) { |
---|
379 | palette[1+i].red = pattern[1+i%2].red; |
---|
380 | palette[1+i].green = pattern[1+i%2].green; |
---|
381 | palette[1+i].blue = pattern[1+i%2].blue; |
---|
382 | palette[1+i].reserved = (uint8) 0; |
---|
383 | } |
---|
384 | } |
---|
385 | /* ------------------------------------------------ */ |
---|
386 | IMAGE_EXPORT(void) Palette_6ColorsBW(RGBQuad *palette) |
---|
387 | /* ------------------------------------------------ */ |
---|
388 | { |
---|
389 | int i; |
---|
390 | uint8 rr = 255,gg = 255, bb = 255; |
---|
391 | RGBQuad pattern[6]; |
---|
392 | |
---|
393 | pattern[0].red = rr; |
---|
394 | pattern[0].green = 0; |
---|
395 | pattern[0].blue = 0; |
---|
396 | |
---|
397 | pattern[1].red = 0; |
---|
398 | pattern[1].green = gg; |
---|
399 | pattern[1].blue = 0; |
---|
400 | |
---|
401 | pattern[2].red = 0; |
---|
402 | pattern[2].green = 0; |
---|
403 | pattern[2].blue = bb; |
---|
404 | |
---|
405 | pattern[3].red = rr; |
---|
406 | pattern[3].green = gg; |
---|
407 | pattern[3].blue = 0; |
---|
408 | |
---|
409 | pattern[4].red = rr; |
---|
410 | pattern[4].green = 0; |
---|
411 | pattern[4].blue = bb; |
---|
412 | |
---|
413 | pattern[5].red = 0; |
---|
414 | pattern[5].green = gg; |
---|
415 | pattern[5].blue = bb; |
---|
416 | |
---|
417 | for(i=0; i<255; i++) { |
---|
418 | palette[1+i].red = pattern[i%6].red; |
---|
419 | palette[1+i].green = pattern[i%6].green; |
---|
420 | palette[1+i].blue = pattern[i%6].blue; |
---|
421 | palette[1+i].reserved = (uint8) 0; |
---|
422 | } |
---|
423 | palette[0].blue = (uint8) 0; |
---|
424 | palette[0].green = (uint8) 0; |
---|
425 | palette[0].red = (uint8) 0; |
---|
426 | palette[0].reserved = (uint8) 0; |
---|
427 | |
---|
428 | palette[255].blue = (uint8) 255; |
---|
429 | palette[255].green = (uint8) 255; |
---|
430 | palette[255].red = (uint8) 255; |
---|
431 | palette[255].reserved = (uint8) 0; |
---|
432 | } |
---|
433 | /* ---------------------------------------------- */ |
---|
434 | IMAGE_EXPORT(void) Palette_6Colors(RGBQuad *palette) |
---|
435 | /* ---------------------------------------------- */ |
---|
436 | { |
---|
437 | int i; |
---|
438 | uint8 rr = 255,gg = 255, bb = 255; |
---|
439 | RGBQuad pattern[6]; |
---|
440 | |
---|
441 | pattern[0].red = rr; |
---|
442 | pattern[0].green = 0; |
---|
443 | pattern[0].blue = 0; |
---|
444 | |
---|
445 | pattern[1].red = 0; |
---|
446 | pattern[1].green = gg; |
---|
447 | pattern[1].blue = 0; |
---|
448 | |
---|
449 | pattern[2].red = 0; |
---|
450 | pattern[2].green = 0; |
---|
451 | pattern[2].blue = bb; |
---|
452 | |
---|
453 | pattern[3].red = rr; |
---|
454 | pattern[3].green = gg; |
---|
455 | pattern[3].blue = 0; |
---|
456 | |
---|
457 | pattern[4].red = rr; |
---|
458 | pattern[4].green = 0; |
---|
459 | pattern[4].blue = bb; |
---|
460 | |
---|
461 | pattern[5].red = 0; |
---|
462 | pattern[5].green = gg; |
---|
463 | pattern[5].blue = bb; |
---|
464 | |
---|
465 | for(i=0; i<256; i++) { |
---|
466 | palette[i].red = pattern[i%6].red; |
---|
467 | palette[i].green = pattern[i%6].green; |
---|
468 | palette[i].blue = pattern[i%6].blue; |
---|
469 | palette[i].reserved = (uint8) 0; |
---|
470 | } |
---|
471 | } |
---|
472 | /* -------------------------------------------------- */ |
---|
473 | IMAGE_EXPORT(void) Palette_6Colors_Red(RGBQuad *palette) |
---|
474 | /* -------------------------------------------------- */ |
---|
475 | { |
---|
476 | int i; |
---|
477 | uint8 rr = 255,gg = 255, bb = 255; |
---|
478 | RGBQuad pattern[6]; |
---|
479 | |
---|
480 | pattern[0].red = rr; |
---|
481 | pattern[0].green = 0; |
---|
482 | pattern[0].blue = 0; |
---|
483 | |
---|
484 | pattern[1].red = 0; |
---|
485 | pattern[1].green = gg; |
---|
486 | pattern[1].blue = 0; |
---|
487 | |
---|
488 | pattern[2].red = 0; |
---|
489 | pattern[2].green = 0; |
---|
490 | pattern[2].blue = bb; |
---|
491 | |
---|
492 | pattern[3].red = rr; |
---|
493 | pattern[3].green = gg; |
---|
494 | pattern[3].blue = 0; |
---|
495 | |
---|
496 | pattern[4].red = rr; |
---|
497 | pattern[4].green = 0; |
---|
498 | pattern[4].blue = bb; |
---|
499 | |
---|
500 | pattern[5].red = 0; |
---|
501 | pattern[5].green = gg; |
---|
502 | pattern[5].blue = bb; |
---|
503 | |
---|
504 | /* rouge en 0 */ |
---|
505 | palette[0].red = pattern[0].red; |
---|
506 | palette[0].green = pattern[0].green; |
---|
507 | palette[0].blue = pattern[0].blue; |
---|
508 | |
---|
509 | for(i=0; i<255; i++) { |
---|
510 | palette[1+i].red = pattern[1+i%5].red; |
---|
511 | palette[1+i].green = pattern[1+i%5].green; |
---|
512 | palette[1+i].blue = pattern[1+i%5].blue; |
---|
513 | palette[1+i].reserved = (uint8) 0; |
---|
514 | } |
---|
515 | } |
---|
516 | /* ------------------------------------------------- */ |
---|
517 | IMAGE_EXPORT(void) Palette_18ColorsBW(RGBQuad *palette) |
---|
518 | /* ------------------------------------------------- */ |
---|
519 | { |
---|
520 | int i; |
---|
521 | uint8 rr = 255,gg = 255, bb = 255; |
---|
522 | uint8 r =127, g = 127, b = 127; |
---|
523 | |
---|
524 | RGBQuad pattern[18]; |
---|
525 | |
---|
526 | pattern[0].red = rr; |
---|
527 | pattern[0].green = 0; |
---|
528 | pattern[0].blue = 0; |
---|
529 | |
---|
530 | pattern[1].red = 0; |
---|
531 | pattern[1].green = gg; |
---|
532 | pattern[1].blue = 0; |
---|
533 | |
---|
534 | pattern[2].red = 0; |
---|
535 | pattern[2].green = 0; |
---|
536 | pattern[2].blue = bb; |
---|
537 | |
---|
538 | pattern[3].red = rr; |
---|
539 | pattern[3].green = gg; |
---|
540 | pattern[3].blue = 0; |
---|
541 | |
---|
542 | pattern[4].red = rr; |
---|
543 | pattern[4].green = 0; |
---|
544 | pattern[4].blue = bb; |
---|
545 | |
---|
546 | pattern[5].red = 0; |
---|
547 | pattern[5].green = gg; |
---|
548 | pattern[5].blue = bb; |
---|
549 | |
---|
550 | pattern[6].red = r; |
---|
551 | pattern[6].green = 0; |
---|
552 | pattern[6].blue = 0; |
---|
553 | |
---|
554 | pattern[7].red = 0; |
---|
555 | pattern[7].green = g; |
---|
556 | pattern[7].blue = 0; |
---|
557 | |
---|
558 | pattern[8].red = 0; |
---|
559 | pattern[8].green = 0; |
---|
560 | pattern[8].blue = b; |
---|
561 | |
---|
562 | pattern[9].red = r; |
---|
563 | pattern[9].green = g; |
---|
564 | pattern[9].blue = 0; |
---|
565 | |
---|
566 | pattern[10].red = r; |
---|
567 | pattern[10].green = 0; |
---|
568 | pattern[10].blue = b; |
---|
569 | |
---|
570 | pattern[11].red = 0; |
---|
571 | pattern[11].green = g; |
---|
572 | pattern[11].blue = b; |
---|
573 | |
---|
574 | pattern[12].red = rr; |
---|
575 | pattern[12].green = g; |
---|
576 | pattern[12].blue = 0; |
---|
577 | |
---|
578 | pattern[13].red = rr; |
---|
579 | pattern[13].green = 0; |
---|
580 | pattern[13].blue = b; |
---|
581 | |
---|
582 | pattern[14].red = 0; |
---|
583 | pattern[14].green = gg; |
---|
584 | pattern[14].blue = b; |
---|
585 | |
---|
586 | pattern[15].red = r; |
---|
587 | pattern[15].green = gg; |
---|
588 | pattern[15].blue = 0; |
---|
589 | |
---|
590 | pattern[16].red = r; |
---|
591 | pattern[16].green = 0; |
---|
592 | pattern[16].blue = bb; |
---|
593 | |
---|
594 | pattern[17].red = 0; |
---|
595 | pattern[17].green = g; |
---|
596 | pattern[17].blue = bb; |
---|
597 | |
---|
598 | for(i=0; i<255; i++) { |
---|
599 | palette[1+i].red = pattern[i%18].red; |
---|
600 | palette[1+i].green = pattern[i%18].green; |
---|
601 | palette[1+i].blue = pattern[i%18].blue; |
---|
602 | palette[1+i].reserved = (uint8) 0; |
---|
603 | } |
---|
604 | palette[0].blue = (uint8) 0; |
---|
605 | palette[0].green = (uint8) 0; |
---|
606 | palette[0].red = (uint8) 0; |
---|
607 | palette[0].reserved = (uint8) 0; |
---|
608 | |
---|
609 | palette[255].blue = (uint8) 255; |
---|
610 | palette[255].green = (uint8) 255; |
---|
611 | palette[255].red = (uint8) 255; |
---|
612 | palette[255].reserved = (uint8) 0; |
---|
613 | } |
---|
614 | /* ----------------------------------------------- */ |
---|
615 | IMAGE_EXPORT(void) Palette_18Colors(RGBQuad *palette) |
---|
616 | /* ----------------------------------------------- */ |
---|
617 | { |
---|
618 | int i; |
---|
619 | uint8 rr = 255,gg = 255, bb = 255; |
---|
620 | uint8 r =127, g = 127, b = 127; |
---|
621 | |
---|
622 | RGBQuad pattern[18]; |
---|
623 | |
---|
624 | pattern[0].red = rr; |
---|
625 | pattern[0].green = 0; |
---|
626 | pattern[0].blue = 0; |
---|
627 | |
---|
628 | pattern[1].red = 0; |
---|
629 | pattern[1].green = gg; |
---|
630 | pattern[1].blue = 0; |
---|
631 | |
---|
632 | pattern[2].red = 0; |
---|
633 | pattern[2].green = 0; |
---|
634 | pattern[2].blue = bb; |
---|
635 | |
---|
636 | pattern[3].red = rr; |
---|
637 | pattern[3].green = gg; |
---|
638 | pattern[3].blue = 0; |
---|
639 | |
---|
640 | pattern[4].red = rr; |
---|
641 | pattern[4].green = 0; |
---|
642 | pattern[4].blue = bb; |
---|
643 | |
---|
644 | pattern[5].red = 0; |
---|
645 | pattern[5].green = gg; |
---|
646 | pattern[5].blue = bb; |
---|
647 | |
---|
648 | pattern[6].red = r; |
---|
649 | pattern[6].green = 0; |
---|
650 | pattern[6].blue = 0; |
---|
651 | |
---|
652 | pattern[7].red = 0; |
---|
653 | pattern[7].green = g; |
---|
654 | pattern[7].blue = 0; |
---|
655 | |
---|
656 | pattern[8].red = 0; |
---|
657 | pattern[8].green = 0; |
---|
658 | pattern[8].blue = b; |
---|
659 | |
---|
660 | pattern[9].red = r; |
---|
661 | pattern[9].green = g; |
---|
662 | pattern[9].blue = 0; |
---|
663 | |
---|
664 | pattern[10].red = r; |
---|
665 | pattern[10].green = 0; |
---|
666 | pattern[10].blue = b; |
---|
667 | |
---|
668 | pattern[11].red = 0; |
---|
669 | pattern[11].green = g; |
---|
670 | pattern[11].blue = b; |
---|
671 | |
---|
672 | pattern[12].red = rr; |
---|
673 | pattern[12].green = g; |
---|
674 | pattern[12].blue = 0; |
---|
675 | |
---|
676 | pattern[13].red = rr; |
---|
677 | pattern[13].green = 0; |
---|
678 | pattern[13].blue = b; |
---|
679 | |
---|
680 | pattern[14].red = 0; |
---|
681 | pattern[14].green = gg; |
---|
682 | pattern[14].blue = b; |
---|
683 | |
---|
684 | pattern[15].red = r; |
---|
685 | pattern[15].green = gg; |
---|
686 | pattern[15].blue = 0; |
---|
687 | |
---|
688 | pattern[16].red = r; |
---|
689 | pattern[16].green = 0; |
---|
690 | pattern[16].blue = bb; |
---|
691 | |
---|
692 | pattern[17].red = 0; |
---|
693 | pattern[17].green = g; |
---|
694 | pattern[17].blue = bb; |
---|
695 | |
---|
696 | for(i=0; i<256; i++) { |
---|
697 | palette[i].red = pattern[i%18].red; |
---|
698 | palette[i].green = pattern[i%18].green; |
---|
699 | palette[i].blue = pattern[i%18].blue; |
---|
700 | palette[i].reserved = (uint8) 0; |
---|
701 | } |
---|
702 | } |
---|
703 | /* ------------------------------------------------- */ |
---|
704 | IMAGE_EXPORT(void) Palette_64ColorsBW(RGBQuad *palette) |
---|
705 | /* ------------------------------------------------- */ |
---|
706 | { |
---|
707 | int r, g, b; |
---|
708 | int i, m; |
---|
709 | //uint8 x1 = 64, x2 = 128, x3 = 192, x4 = 255; |
---|
710 | uint8 X[4]; |
---|
711 | //RGBQuad pattern[64]; |
---|
712 | |
---|
713 | X[0] = 255; |
---|
714 | X[1] = 192; |
---|
715 | X[2] = 128; |
---|
716 | X[3] = 64; |
---|
717 | |
---|
718 | m = 1; |
---|
719 | for(r=0; r<4; r++) { |
---|
720 | for(g=0; g<4; g++) { |
---|
721 | for(b=0; b<4; b++) { |
---|
722 | palette[m].red = X[r]; |
---|
723 | palette[m].green = X[g]; |
---|
724 | palette[m].blue = X[b]; |
---|
725 | m++; |
---|
726 | } |
---|
727 | } |
---|
728 | } |
---|
729 | |
---|
730 | for(i=0; i<255-(1+m); i++) { |
---|
731 | palette[1+m+i].red = palette[i%m].red; |
---|
732 | palette[1+m+i].green = palette[i%m].green; |
---|
733 | palette[1+m+i].blue = palette[i%m].blue; |
---|
734 | palette[1+m+i].reserved = (uint8) 0; |
---|
735 | } |
---|
736 | palette[0].blue = (uint8) 0; |
---|
737 | palette[0].green = (uint8) 0; |
---|
738 | palette[0].red = (uint8) 0; |
---|
739 | palette[0].reserved = (uint8) 0; |
---|
740 | |
---|
741 | palette[255].blue = (uint8) 255; |
---|
742 | palette[255].green = (uint8) 255; |
---|
743 | palette[255].red = (uint8) 255; |
---|
744 | palette[255].reserved = (uint8) 0; |
---|
745 | } |
---|
746 | /* ------------------------------------------------- */ |
---|
747 | IMAGE_EXPORT(void) Palette_256ColorsBW(RGBQuad *palette) |
---|
748 | /* ------------------------------------------------- */ |
---|
749 | { |
---|
750 | int r, g, b; |
---|
751 | int m; |
---|
752 | //uint8 x1 = 64, x2 = 128, x3 = 192, x4 = 255; |
---|
753 | uint8 X[8], xr, xg, xb; |
---|
754 | //RGBQuad pattern[64]; |
---|
755 | |
---|
756 | X[0] = 255; |
---|
757 | X[1] = 224; |
---|
758 | X[2] = 192; |
---|
759 | X[3] = 160; |
---|
760 | X[4] = 128; |
---|
761 | X[5] = 96; |
---|
762 | X[6] = 64; |
---|
763 | X[7] = 32; |
---|
764 | |
---|
765 | m = 1; |
---|
766 | for(r=0; r<8; r++) { |
---|
767 | for(g=0; g<8; g++) { |
---|
768 | for(b=0; b<8; b++) { |
---|
769 | if(m<255) { |
---|
770 | xr = X[r]; xg = X[g]; xb = X[b]; |
---|
771 | palette[m].red = xr; |
---|
772 | palette[m].green = xg; |
---|
773 | palette[m].blue = xb; |
---|
774 | if((xr!=255) && (xg!=255) && (xb!=255)) m++; |
---|
775 | if((xr!=000) && (xg!=000) && (xb!=000)) m++; |
---|
776 | } |
---|
777 | } |
---|
778 | } |
---|
779 | } |
---|
780 | |
---|
781 | palette[0].blue = (uint8) 0; |
---|
782 | palette[0].green = (uint8) 0; |
---|
783 | palette[0].red = (uint8) 0; |
---|
784 | palette[0].reserved = (uint8) 0; |
---|
785 | |
---|
786 | palette[255].blue = (uint8) 255; |
---|
787 | palette[255].green = (uint8) 255; |
---|
788 | palette[255].red = (uint8) 255; |
---|
789 | palette[255].reserved = (uint8) 0; |
---|
790 | } |
---|
791 | /* ----------------------------------------------------- */ |
---|
792 | IMAGE_EXPORT(void) Palette_18ColorsBW_Red(RGBQuad *palette) |
---|
793 | /* ----------------------------------------------------- */ |
---|
794 | { |
---|
795 | int i; |
---|
796 | uint8 rr = 255,gg = 255, bb = 255; |
---|
797 | uint8 r =127, g = 127, b = 127; |
---|
798 | |
---|
799 | RGBQuad pattern[18]; |
---|
800 | |
---|
801 | pattern[0].red = rr; |
---|
802 | pattern[0].green = 0; |
---|
803 | pattern[0].blue = 0; |
---|
804 | |
---|
805 | pattern[1].red = 0; |
---|
806 | pattern[1].green = gg; |
---|
807 | pattern[1].blue = 0; |
---|
808 | |
---|
809 | pattern[2].red = 0; |
---|
810 | pattern[2].green = 0; |
---|
811 | pattern[2].blue = bb; |
---|
812 | |
---|
813 | pattern[3].red = rr; |
---|
814 | pattern[3].green = gg; |
---|
815 | pattern[3].blue = 0; |
---|
816 | |
---|
817 | pattern[4].red = rr; |
---|
818 | pattern[4].green = 0; |
---|
819 | pattern[4].blue = bb; |
---|
820 | |
---|
821 | pattern[5].red = 0; |
---|
822 | pattern[5].green = gg; |
---|
823 | pattern[5].blue = bb; |
---|
824 | |
---|
825 | pattern[6].red = r; |
---|
826 | pattern[6].green = 0; |
---|
827 | pattern[6].blue = 0; |
---|
828 | |
---|
829 | pattern[7].red = 0; |
---|
830 | pattern[7].green = g; |
---|
831 | pattern[7].blue = 0; |
---|
832 | |
---|
833 | pattern[8].red = 0; |
---|
834 | pattern[8].green = 0; |
---|
835 | pattern[8].blue = b; |
---|
836 | |
---|
837 | pattern[9].red = r; |
---|
838 | pattern[9].green = g; |
---|
839 | pattern[9].blue = 0; |
---|
840 | |
---|
841 | pattern[10].red = r; |
---|
842 | pattern[10].green = 0; |
---|
843 | pattern[10].blue = b; |
---|
844 | |
---|
845 | pattern[11].red = 0; |
---|
846 | pattern[11].green = g; |
---|
847 | pattern[11].blue = b; |
---|
848 | |
---|
849 | pattern[12].red = rr; |
---|
850 | pattern[12].green = g; |
---|
851 | pattern[12].blue = 0; |
---|
852 | |
---|
853 | pattern[13].red = rr; |
---|
854 | pattern[13].green = 0; |
---|
855 | pattern[13].blue = b; |
---|
856 | |
---|
857 | pattern[14].red = 0; |
---|
858 | pattern[14].green = gg; |
---|
859 | pattern[14].blue = b; |
---|
860 | |
---|
861 | pattern[15].red = r; |
---|
862 | pattern[15].green = gg; |
---|
863 | pattern[15].blue = 0; |
---|
864 | |
---|
865 | pattern[16].red = r; |
---|
866 | pattern[16].green = 0; |
---|
867 | pattern[16].blue = bb; |
---|
868 | |
---|
869 | pattern[17].red = 0; |
---|
870 | pattern[17].green = g; |
---|
871 | pattern[17].blue = bb; |
---|
872 | |
---|
873 | for(i=0; i<254; i++) { |
---|
874 | palette[2+i].red = pattern[1+i%17].red; |
---|
875 | palette[2+i].green = pattern[1+i%17].green; |
---|
876 | palette[2+i].blue = pattern[1+i%17].blue; |
---|
877 | palette[2+i].reserved = (uint8) 0; |
---|
878 | } |
---|
879 | /* noir en 0 */ |
---|
880 | palette[0].red = 0; |
---|
881 | palette[0].green = 0; |
---|
882 | palette[0].blue = 0; |
---|
883 | /* rouge en 1 */ |
---|
884 | palette[1].red = rr; |
---|
885 | palette[1].green = 0; |
---|
886 | palette[1].blue = 0; |
---|
887 | /* blanc en 255 */ |
---|
888 | palette[255].red = rr; |
---|
889 | palette[255].green = gg; |
---|
890 | palette[255].blue = gg; |
---|
891 | } |
---|
892 | /* -------------------------------------------------------------- */ |
---|
893 | IMAGE_EXPORT(void) Palette_18ColorsBW_RedGreenBlue(RGBQuad *palette) |
---|
894 | /* -------------------------------------------------------------- */ |
---|
895 | { |
---|
896 | int i; |
---|
897 | uint8 i0 = 255; |
---|
898 | uint8 i1 = 127; |
---|
899 | //uint8 i2 = 63; |
---|
900 | |
---|
901 | RGBQuad pattern[18]; |
---|
902 | |
---|
903 | /* 0+0 */ |
---|
904 | pattern[0].red = i0; |
---|
905 | pattern[0].green = i0; |
---|
906 | pattern[0].blue = 0; |
---|
907 | |
---|
908 | pattern[1].red = i0; |
---|
909 | pattern[1].green = 0; |
---|
910 | pattern[1].blue = i0; |
---|
911 | |
---|
912 | pattern[2].red = 0; |
---|
913 | pattern[2].green = i0; |
---|
914 | pattern[2].blue = i0; |
---|
915 | |
---|
916 | /* 1 */ |
---|
917 | pattern[3].red = i1; |
---|
918 | pattern[3].green = 0; |
---|
919 | pattern[3].blue = 0; |
---|
920 | |
---|
921 | pattern[4].red = 0; |
---|
922 | pattern[4].green = i1; |
---|
923 | pattern[4].blue = 0; |
---|
924 | |
---|
925 | pattern[5].red = 0; |
---|
926 | pattern[5].green = 0; |
---|
927 | pattern[5].blue = i1; |
---|
928 | |
---|
929 | /* 1+1 */ |
---|
930 | pattern[6].red = i1; |
---|
931 | pattern[6].green = i1; |
---|
932 | pattern[6].blue = 0; |
---|
933 | |
---|
934 | pattern[7].red = i1; |
---|
935 | pattern[7].green = 0; |
---|
936 | pattern[7].blue = i1; |
---|
937 | |
---|
938 | pattern[8].red = 0; |
---|
939 | pattern[8].green = i1; |
---|
940 | pattern[8].blue = i1; |
---|
941 | |
---|
942 | /* 0+1 */ |
---|
943 | pattern[9].red = i0; |
---|
944 | pattern[9].green = i1; |
---|
945 | pattern[9].blue = 0; |
---|
946 | |
---|
947 | pattern[10].red = i0; |
---|
948 | pattern[10].green = 0; |
---|
949 | pattern[10].blue = i1; |
---|
950 | |
---|
951 | pattern[11].red = 0; |
---|
952 | pattern[11].green = i0; |
---|
953 | pattern[11].blue = i1; |
---|
954 | |
---|
955 | pattern[12].red = i1; |
---|
956 | pattern[12].green = i0; |
---|
957 | pattern[12].blue = 0; |
---|
958 | |
---|
959 | pattern[13].red = i1; |
---|
960 | pattern[13].green = 0; |
---|
961 | pattern[13].blue = i0; |
---|
962 | |
---|
963 | pattern[14].red = 0; |
---|
964 | pattern[14].green = i1; |
---|
965 | pattern[14].blue = i0; |
---|
966 | |
---|
967 | for(i=0; i<=250; i++) { |
---|
968 | palette[4+i].red = pattern[i%14].red; |
---|
969 | palette[4+i].green = pattern[i%14].green; |
---|
970 | palette[4+i].blue = pattern[i%14].blue; |
---|
971 | palette[4+i].reserved = (uint8) 0; |
---|
972 | } |
---|
973 | |
---|
974 | /* noir en 0 */ |
---|
975 | palette[0].red = 0; |
---|
976 | palette[0].green = 0; |
---|
977 | palette[0].blue = 0; |
---|
978 | |
---|
979 | /* rouge en 1 */ |
---|
980 | palette[1].red = i0; |
---|
981 | palette[1].green = 0; |
---|
982 | palette[1].blue = 0; |
---|
983 | |
---|
984 | /* vert en 2 */ |
---|
985 | palette[2].red = 0; |
---|
986 | palette[2].green = i0; |
---|
987 | palette[2].blue = 0; |
---|
988 | |
---|
989 | /* bleu en 3 */ |
---|
990 | palette[2].red = 0; |
---|
991 | palette[2].green = i0; |
---|
992 | palette[2].blue = 0; |
---|
993 | |
---|
994 | /* blanc en 255 */ |
---|
995 | palette[255].red = i0; |
---|
996 | palette[255].green = i0; |
---|
997 | palette[255].blue = i0; |
---|
998 | } |
---|
999 | /* ---------------------------------------------------- */ |
---|
1000 | IMAGE_EXPORT(void) Palette_3ColorsGrayBW(RGBQuad *palette) |
---|
1001 | /* ---------------------------------------------------- */ |
---|
1002 | { |
---|
1003 | int i; |
---|
1004 | |
---|
1005 | Palette_3ColorsBW(palette); |
---|
1006 | |
---|
1007 | for(i=128; i<256; i++) { |
---|
1008 | palette[i].red = 1 + 2*(i-128); |
---|
1009 | palette[i].green = 1 + 2*(i-128); |
---|
1010 | palette[i].blue = 1 + 2*(i-128); |
---|
1011 | palette[i].reserved = (uint8) 0; |
---|
1012 | } |
---|
1013 | /* palette[255] = blanc <- OK */ |
---|
1014 | } |
---|
1015 | /* -------------------------------------------------- */ |
---|
1016 | IMAGE_EXPORT(void) Palette_3ColorsGray(RGBQuad *palette) |
---|
1017 | /* -------------------------------------------------- */ |
---|
1018 | { |
---|
1019 | int i; |
---|
1020 | |
---|
1021 | Palette_3Colors(palette); |
---|
1022 | |
---|
1023 | for(i=128; i<256; i++) { |
---|
1024 | palette[i].red = 1 + 2*(i-128); |
---|
1025 | palette[i].green = 1 + 2*(i-128); |
---|
1026 | palette[i].blue = 1 + 2*(i-128); |
---|
1027 | palette[i].reserved = (uint8) 0; |
---|
1028 | } |
---|
1029 | } |
---|
1030 | /* ---------------------------------------------------- */ |
---|
1031 | IMAGE_EXPORT(void) Palette_6ColorsGrayBW(RGBQuad *palette) |
---|
1032 | /* ---------------------------------------------------- */ |
---|
1033 | { |
---|
1034 | int i; |
---|
1035 | |
---|
1036 | Palette_6ColorsBW(palette); |
---|
1037 | |
---|
1038 | for(i=128; i<256; i++) { |
---|
1039 | palette[i].red = 1 + 2*(i-128); |
---|
1040 | palette[i].green = 1 + 2*(i-128); |
---|
1041 | palette[i].blue = 1 + 2*(i-128); |
---|
1042 | palette[i].reserved = (uint8) 0; |
---|
1043 | } |
---|
1044 | } |
---|
1045 | /* -------------------------------------------------- */ |
---|
1046 | IMAGE_EXPORT(void) Palette_6ColorsGray(RGBQuad *palette) |
---|
1047 | /* -------------------------------------------------- */ |
---|
1048 | { |
---|
1049 | int i; |
---|
1050 | |
---|
1051 | Palette_6Colors(palette); |
---|
1052 | |
---|
1053 | for(i=128; i<256; i++) { |
---|
1054 | palette[i].red = 1 + 2*(i-128); |
---|
1055 | palette[i].green = 1 + 2*(i-128); |
---|
1056 | palette[i].blue = 1 + 2*(i-128); |
---|
1057 | palette[i].reserved = (uint8) 0; |
---|
1058 | } |
---|
1059 | } |
---|
1060 | /* ----------------------------------------------------- */ |
---|
1061 | IMAGE_EXPORT(void) Palette_18ColorsGrayBW(RGBQuad *palette) |
---|
1062 | /* ----------------------------------------------------- */ |
---|
1063 | { |
---|
1064 | int i; |
---|
1065 | |
---|
1066 | Palette_18ColorsBW(palette); |
---|
1067 | |
---|
1068 | for(i=128; i<256; i++) { |
---|
1069 | palette[i].red = 1 + 2*(i-128); |
---|
1070 | palette[i].green = 1 + 2*(i-128); |
---|
1071 | palette[i].blue = 1 + 2*(i-128); |
---|
1072 | palette[i].reserved = (uint8) 0; |
---|
1073 | } |
---|
1074 | } |
---|
1075 | /* --------------------------------------------------- */ |
---|
1076 | IMAGE_EXPORT(void) Palette_18ColorsGray(RGBQuad *palette) |
---|
1077 | /* --------------------------------------------------- */ |
---|
1078 | { |
---|
1079 | int i; |
---|
1080 | |
---|
1081 | Palette_18Colors(palette); |
---|
1082 | |
---|
1083 | for(i=128; i<256; i++) { |
---|
1084 | palette[i].red = 1 + 2*(i-128); |
---|
1085 | palette[i].green = 1 + 2*(i-128); |
---|
1086 | palette[i].blue = 1 + 2*(i-128); |
---|
1087 | palette[i].reserved = (uint8) 0; |
---|
1088 | } |
---|
1089 | } |
---|
1090 | /* -------------------------------------------------------------------- */ |
---|
1091 | //IMAGE_EXPORT(void) Palette_PackGrayLower(Image *src, Lut *lut, Image *dst) |
---|
1092 | /* -------------------------------------------------------------------- */ |
---|
1093 | /*{ |
---|
1094 | int k; |
---|
1095 | uint8 *l = (uint8*) Lut_Get_Data(lut); |
---|
1096 | |
---|
1097 | for(k=0; k<256; k++) { |
---|
1098 | l[k] = (uint8) (k >> 1); |
---|
1099 | } |
---|
1100 | |
---|
1101 | Lut_Apply(src, lut, dst); |
---|
1102 | }*/ |
---|
1103 | /* -------------------------------------------------------------------- */ |
---|
1104 | //IMAGE_EXPORT(void) Palette_PackGrayUpper(Image *src, Lut *lut, Image *dst) |
---|
1105 | /* -------------------------------------------------------------------- */ |
---|
1106 | /*{ |
---|
1107 | int k; |
---|
1108 | uint8 *l = (uint8*) Lut_Get_Data(lut); |
---|
1109 | |
---|
1110 | for(k=0; k<256; k++) { |
---|
1111 | l[k] = (uint8) 128 + (k >> 1); |
---|
1112 | } |
---|
1113 | |
---|
1114 | Lut_Apply(src, lut, dst); |
---|
1115 | }*/ |
---|
1116 | /* ---------------------------------------------- */ |
---|
1117 | IMAGE_EXPORT(void) Palette_2Colors(RGBQuad *palette) |
---|
1118 | /* ---------------------------------------------- */ |
---|
1119 | { |
---|
1120 | int i, level; |
---|
1121 | |
---|
1122 | RGBQuad pattern[2]; |
---|
1123 | |
---|
1124 | pattern[0].red = 0; |
---|
1125 | pattern[0].green = 0; |
---|
1126 | pattern[0].blue = 0; |
---|
1127 | |
---|
1128 | level = 255; |
---|
1129 | |
---|
1130 | pattern[1].red = level; |
---|
1131 | pattern[1].green = level; |
---|
1132 | pattern[1].blue = level; |
---|
1133 | |
---|
1134 | for(i=0; i<256; i++) { |
---|
1135 | palette[i].red = pattern[i%2].red; |
---|
1136 | palette[i].green = pattern[i%2].green; |
---|
1137 | palette[i].blue = pattern[i%2].blue; |
---|
1138 | palette[i].reserved = (uint8) 0; |
---|
1139 | } |
---|
1140 | } |
---|
1141 | /* ---------------------------------------------- */ |
---|
1142 | IMAGE_EXPORT(void) Palette_4Colors(RGBQuad *palette) |
---|
1143 | /* ---------------------------------------------- */ |
---|
1144 | { |
---|
1145 | int i, level; |
---|
1146 | |
---|
1147 | RGBQuad pattern[4]; |
---|
1148 | |
---|
1149 | for(i=0; i<2; i++) { |
---|
1150 | level = (i<<8) - 1; |
---|
1151 | pattern[i].red = level; |
---|
1152 | pattern[0].green = level; |
---|
1153 | pattern[0].blue = level; |
---|
1154 | } |
---|
1155 | |
---|
1156 | for(i=0; i<256; i++) { |
---|
1157 | palette[i].red = pattern[i%2].red; |
---|
1158 | palette[i].green = pattern[i%2].green; |
---|
1159 | palette[i].blue = pattern[i%2].blue; |
---|
1160 | palette[i].reserved = (uint8) 0; |
---|
1161 | } |
---|
1162 | } |
---|
1163 | /* ---------------------------------------------- */ |
---|
1164 | IMAGE_EXPORT(void) Palette_16Colors(RGBQuad *palette) |
---|
1165 | /* ---------------------------------------------- */ |
---|
1166 | { |
---|
1167 | int i, level; |
---|
1168 | |
---|
1169 | RGBQuad pattern[16]; |
---|
1170 | |
---|
1171 | for(i=0; i<4; i++) { |
---|
1172 | level = (i<<8) - 1; |
---|
1173 | pattern[i].red = level; |
---|
1174 | pattern[0].green = level; |
---|
1175 | pattern[0].blue = level; |
---|
1176 | } |
---|
1177 | |
---|
1178 | for(i=0; i<256; i++) { |
---|
1179 | palette[i].red = pattern[i%2].red; |
---|
1180 | palette[i].green = pattern[i%2].green; |
---|
1181 | palette[i].blue = pattern[i%2].blue; |
---|
1182 | palette[i].reserved = (uint8) 0; |
---|
1183 | } |
---|
1184 | } |
---|