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