Changeset 821 for soft/giet_vm/applications/rosenfeld/src/palette.c
- Timestamp:
- May 6, 2016, 3:06:29 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/applications/rosenfeld/src/palette.c
r772 r821 16 16 17 17 18 #ifdef CLI19 18 #include "nrc_os_config.h" 20 19 #include "nrc.h" 21 #endif22 20 23 21 #include "palette.h" 24 22 25 /* 26 * Modif : 98-11-18 ajout de Save 27 */ 28 29 /* ---------------------------------------------- */ 30 IMAGE_EXPORT(void) Palette_Display(RGBQuad *palette) 31 /* ---------------------------------------------- */ 23 24 /* --------------------------------- */ 25 void Palette_Display(RGBQuad * palette) 26 /* --------------------------------- */ 32 27 { 33 28 int i; … … 37 32 } 38 33 } 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 }*/ 34 35 80 36 /* --------------------------------------------------- */ 81 37 IMAGE_EXPORT(void) Palette_GrayBlue2Red(RGBQuad *palette) 82 /* --------------------------------------------------- */ 83 /* ancien SetupPalette */ 84 { 85 int i; 86 38 /* --------------------------------------------------- */ 39 /* ancien SetupPalette */ 40 { 87 41 /* 88 42 * Partie basse : image en niveau de gris 89 43 */ 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;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; 94 48 palette[i].reserved = 0; 95 49 } … … 98 52 * degrade de bleus puis degrade de rouges 99 53 */ 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;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; 105 59 } 106 60 palette[128].blue = 255; … … 113 67 palette[255].red = 255; 114 68 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++) { 69 } 70 71 72 /* --------------------------------- */ 73 void Palette_Classic(RGBQuad * palette) 74 /* --------------------------------- */ 75 { 76 for (int i = 0; i < 256; i++) { 136 77 palette[i].blue = (uint8) i; 137 78 palette[i].green = (uint8) i; … … 140 81 } 141 82 } 142 /* ------------------------------------------- */ 143 IMAGE_EXPORT(void) Palette_Gray(RGBQuad *palette) 144 /* ------------------------------------------- */145 { 146 int i; 147 148 for (i=0; i<256; i++) {83 84 85 /* ------------------------------ */ 86 void Palette_Gray(RGBQuad * palette) 87 /* ------------------------------ */ 88 { 89 for (int i = 0; i < 256; i++) { 149 90 palette[i].blue = (uint8) i; 150 91 palette[i].green = (uint8) i; … … 154 95 } 155 96 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);97 98 /* --------------------------------- */ 99 void Palette_Pseudo1(RGBQuad * palette) 100 /* --------------------------------- */ 101 { 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); 165 106 palette[i].reserved = 0; 166 107 } … … 170 111 palette[255].reserved = (uint8) 0; 171 112 } 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) */ 113 114 115 /* --------------------------------- */ 116 void Palette_Pseudo2(RGBQuad * palette) 117 /* --------------------------------- */ 118 { 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) */ 181 124 palette[i].reserved = 0; 182 125 } … … 186 129 palette[255].reserved = (uint8) 0; 187 130 } 188 /* ------------------------------------------ */ 189 IMAGE_EXPORT(void) Palette_Hue(RGBQuad *palette) 190 /* ------------------------------------------ */ 131 132 133 /* ----------------------------- */ 134 void Palette_Hue(RGBQuad * palette) 135 /* ----------------------------- */ 191 136 { 192 137 int i; 193 138 double k, r, g, b; /* alpha rgb */ 194 for (i=0; i<255; i++) {139 for (i = 0; i < 255; i++) { 195 140 196 141 k = (double) i / 256; 197 142 198 143 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);144 g = 2.0 * k * PI - (2.0* PI / 3.0); 145 b = 2.0 * k * PI - (4.0* PI / 3.0); 201 146 202 147 palette[i].blue = (uint8) (128.0 * (1.0 + cos(b))); … … 206 151 } 207 152 } 208 /* ------------------------------------------------ */ 209 IMAGE_EXPORT(void) Palette_RandomHue(RGBQuad *palette) 210 /* ------------------------------------------------ */ 153 154 155 /* ----------------------------------- */ 156 void Palette_RandomHue(RGBQuad * palette) 157 /* ----------------------------------- */ 211 158 { 212 159 int i, ii; 213 160 double k, r, g, b; /* alpha rgb */ 214 for (i=0; i<255; i++) {215 216 ii = (3 *i)%256;161 for (i = 0; i < 255; i++) { 162 163 ii = (3 * i) % 256; 217 164 k = (double) (ii / 256); 218 165 219 166 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);167 g = 2.0 * k * PI - (2.0 * PI / 3.0); 168 b = 2.0 * k * PI - (4.0 * PI / 3.0); 222 169 223 170 palette[i].blue = (uint8) (128.0 * (1.0 + cos(b))); … … 227 174 } 228 175 } 229 /* -------------------------------------------- */ 230 IMAGE_EXPORT(void) Palette_HueBW(RGBQuad *palette) 231 /* -------------------------------------------- */ 176 177 178 /* ------------------------------- */ 179 void Palette_HueBW(RGBQuad * palette) 180 /* ------------------------------- */ 232 181 { 233 182 int i; 234 183 double k, r, g, b; /* alpha rgb */ 235 for (i=0; i<255; i++) {184 for (i = 0; i < 255; i++) { 236 185 237 186 k = (double) i / 256; 238 187 239 188 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);189 g = 2.0 * k * PI - (2.0 * PI / 3.0); 190 b = 2.0 * k * PI - (4.0 * PI / 3.0); 242 191 243 192 palette[i].blue = (uint8) (128.0 * (1.0 + cos(b))); … … 256 205 palette[255].reserved = (uint8) 0; 257 206 } 258 /* -------------------------------------------------- */ 259 IMAGE_EXPORT(void) Palette_RandomHueBW(RGBQuad *palette) 260 /* -------------------------------------------------- */ 207 208 209 /* ------------------------------------- */ 210 void Palette_RandomHueBW(RGBQuad * palette) 211 /* ------------------------------------- */ 261 212 { 262 213 int i, ii, im; 263 214 double k, r, g, b; /* alpha rgb */ 264 for (i=0; i<255; i++) {265 266 ii = (7 *i)%256;215 for (i = 0; i < 255; i++) { 216 217 ii = (7 * i) % 256; 267 218 k = (double) ii / 256; 268 219 269 220 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;221 g = 2.0 * k * PI - (2.0 * PI / 3.0); 222 b = 2.0 * k * PI - (4.0 * PI / 3.0); 223 224 im = (i - 27) % 255; 274 225 im = i; 275 226 palette[im].blue = (uint8) (128.0 * (1.0 + cos(b))); … … 288 239 palette[255].reserved = (uint8) 0; 289 240 } 290 /* ------------------------------------------------ */ 291 IMAGE_EXPORT(void) Palette_3ColorsBW(RGBQuad *palette) 292 /* ------------------------------------------------ */ 293 { 294 int i; 295 uint8 rr = 255,gg = 255, bb = 255; 241 242 243 /* ----------------------------------- */ 244 void Palette_3ColorsBW(RGBQuad * palette) 245 /* ----------------------------------- */ 246 { 247 uint8 rr = 255, gg = 255, bb = 255; 296 248 RGBQuad pattern[3]; 297 249 … … 308 260 pattern[2].blue = bb; 309 261 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;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; 315 267 } 316 268 palette[0].blue = (uint8) 0; … … 324 276 palette[255].reserved = (uint8) 0; 325 277 } 326 /* ---------------------------------------------- */ 327 IMAGE_EXPORT(void) Palette_3Colors(RGBQuad *palette) 328 /* ---------------------------------------------- */ 278 279 280 /* --------------------------------- */ 281 void Palette_3Colors(RGBQuad * palette) 282 /* --------------------------------- */ 329 283 { 330 284 int i; 331 uint8 rr = 255, gg = 255, bb = 255;285 uint8 rr = 255, gg = 255, bb = 255; 332 286 RGBQuad pattern[3]; 333 287 … … 344 298 pattern[2].blue = bb; 345 299 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; 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; 304 palette[i].reserved = (uint8) 0; 305 } 306 } 307 308 309 /* ------------------------------------- */ 310 void Palette_3Colors_Red(RGBQuad * palette) 311 /* ------------------------------------- */ 312 { 313 uint8 rr = 255, gg = 255, bb = 255; 359 314 RGBQuad pattern[3]; 360 315 … … 376 331 palette[0].blue = pattern[0].blue; 377 332 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; 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; 338 } 339 } 340 341 342 /* ----------------------------------- */ 343 void Palette_6ColorsBW(RGBQuad * palette) 344 /* ----------------------------------- */ 345 { 346 uint8 rr = 255, gg = 255, bb = 255; 391 347 RGBQuad pattern[6]; 392 348 … … 415 371 pattern[5].blue = bb; 416 372 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;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; 422 378 } 423 379 palette[0].blue = (uint8) 0; … … 431 387 palette[255].reserved = (uint8) 0; 432 388 } 433 /* ---------------------------------------------- */ 434 IMAGE_EXPORT(void) Palette_6Colors(RGBQuad *palette) 435 /* ---------------------------------------------- */ 436 { 437 int i; 438 uint8 rr = 255,gg = 255, bb = 255; 389 390 391 /* --------------------------------- */ 392 void Palette_6Colors(RGBQuad * palette) 393 /* --------------------------------- */ 394 { 395 uint8 rr = 255, gg = 255, bb = 255; 439 396 RGBQuad pattern[6]; 440 397 … … 463 420 pattern[5].blue = bb; 464 421 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; 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; 426 palette[i].reserved = (uint8) 0; 427 } 428 } 429 430 431 /* ------------------------------------- */ 432 void Palette_6Colors_Red(RGBQuad * palette) 433 /* ------------------------------------- */ 434 { 435 uint8 rr = 255, gg = 255, bb = 255; 478 436 RGBQuad pattern[6]; 479 437 … … 507 465 palette[0].blue = pattern[0].blue; 508 466 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 /* ------------------------------------------------- */ 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; 472 } 473 } 474 475 476 /* ------------------------------------ */ 477 void Palette_18ColorsBW(RGBQuad * palette) 478 /* ------------------------------------ */ 519 479 { 520 480 int i; 521 uint8 rr = 255, gg = 255, bb = 255;522 uint8 r =127, g = 127, b = 127;481 uint8 rr = 255, gg = 255, bb = 255; 482 uint8 r = 127, g = 127, b = 127; 523 483 524 484 RGBQuad pattern[18]; … … 596 556 pattern[17].blue = bb; 597 557 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;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; 603 563 } 604 564 palette[0].blue = (uint8) 0; … … 612 572 palette[255].reserved = (uint8) 0; 613 573 } 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; 574 575 576 /* ---------------------------------- */ 577 void Palette_18Colors(RGBQuad * palette) 578 /* ---------------------------------- */ 579 { 580 uint8 rr = 255, gg = 255, bb = 255; 581 uint8 r = 127, g = 127, b = 127; 621 582 622 583 RGBQuad pattern[18]; … … 694 655 pattern[17].blue = bb; 695 656 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; 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; 661 palette[i].reserved = (uint8) 0; 662 } 663 } 664 665 666 /* ------------------------------------ */ 667 void Palette_64ColorsBW(RGBQuad * palette) 668 /* ------------------------------------ */ 669 { 670 int m; 709 671 //uint8 x1 = 64, x2 = 128, x3 = 192, x4 = 255; 710 672 uint8 X[4]; … … 717 679 718 680 m = 1; 719 for (r=0; r<4; r++) {720 for (g=0; g<4; g++) {721 for (b=0; b<4; b++) {681 for (int r = 0; r < 4; r++) { 682 for (int g = 0; g < 4; g++) { 683 for (int b = 0; b < 4; b++) { 722 684 palette[m].red = X[r]; 723 685 palette[m].green = X[g]; … … 728 690 } 729 691 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;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; 735 697 } 736 698 palette[0].blue = (uint8) 0; … … 744 706 palette[255].reserved = (uint8) 0; 745 707 } 746 /* ------------------------------------------------- */ 747 IMAGE_EXPORT(void) Palette_256ColorsBW(RGBQuad *palette) 748 /* ------------------------------------------------- */ 749 { 750 int r, g, b; 708 709 710 /* ------------------------------------- */ 711 void Palette_256ColorsBW(RGBQuad * palette) 712 /* ------------------------------------- */ 713 { 751 714 int m; 752 715 //uint8 x1 = 64, x2 = 128, x3 = 192, x4 = 255; … … 764 727 765 728 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) {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) { 770 733 xr = X[r]; xg = X[g]; xb = X[b]; 771 734 palette[m].red = xr; 772 735 palette[m].green = xg; 773 736 palette[m].blue = xb; 774 if ((xr!=255) && (xg!=255) && (xb!=255)) m++;775 if ((xr!=000) && (xg!=000) && (xb!=000)) m++;737 if ((xr != 255) && (xg != 255) && (xb != 255)) m++; 738 if ((xr != 000) && (xg != 000) && (xb != 000)) m++; 776 739 } 777 740 } … … 789 752 palette[255].reserved = (uint8) 0; 790 753 } 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; 754 755 756 /* ---------------------------------------- */ 757 void Palette_18ColorsBW_Red(RGBQuad * palette) 758 /* ---------------------------------------- */ 759 { 760 uint8 rr = 255, gg = 255, bb = 255; 761 uint8 r = 127, g = 127, b = 127; 798 762 799 763 RGBQuad pattern[18]; … … 871 835 pattern[17].blue = bb; 872 836 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;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; 878 842 } 879 843 /* noir en 0 */ … … 890 854 palette[255].blue = gg; 891 855 } 892 /* -------------------------------------------------------------- */ 893 IMAGE_EXPORT(void) Palette_18ColorsBW_RedGreenBlue(RGBQuad *palette) 894 /* -------------------------------------------------------------- */ 895 { 896 int i; 856 857 858 /* ------------------------------------------------- */ 859 void Palette_18ColorsBW_RedGreenBlue(RGBQuad * palette) 860 /* ------------------------------------------------- */ 861 { 897 862 uint8 i0 = 255; 898 863 uint8 i1 = 127; … … 965 930 pattern[14].blue = i0; 966 931 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;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; 972 937 } 973 938 … … 997 962 palette[255].blue = i0; 998 963 } 999 /* ---------------------------------------------------- */ 1000 IMAGE_EXPORT(void) Palette_3ColorsGrayBW(RGBQuad *palette) 1001 /* ---------------------------------------------------- */1002 { 1003 int i; 1004 964 965 966 /* --------------------------------------- */ 967 void Palette_3ColorsGrayBW(RGBQuad * palette) 968 /* --------------------------------------- */ 969 { 1005 970 Palette_3ColorsBW(palette); 1006 971 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 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); 976 palette[i].reserved = (uint8) 0; 977 } 978 } 979 980 981 /* ------------------------------------- */ 982 void Palette_3ColorsGray(RGBQuad * palette) 983 /* ------------------------------------- */ 984 { 1021 985 Palette_3Colors(palette); 1022 986 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 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); 991 palette[i].reserved = (uint8) 0; 992 } 993 } 994 995 996 /* --------------------------------------- */ 997 void Palette_6ColorsGrayBW(RGBQuad * palette) 998 /* --------------------------------------- */ 999 { 1036 1000 Palette_6ColorsBW(palette); 1037 1001 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 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); 1006 palette[i].reserved = (uint8) 0; 1007 } 1008 } 1009 1010 1011 /* ------------------------------------- */ 1012 void Palette_6ColorsGray(RGBQuad * palette) 1013 /* ------------------------------------- */ 1014 { 1051 1015 Palette_6Colors(palette); 1052 1016 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 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); 1021 palette[i].reserved = (uint8) 0; 1022 } 1023 } 1024 1025 1026 /* ---------------------------------------- */ 1027 void Palette_18ColorsGrayBW(RGBQuad * palette) 1028 /* ---------------------------------------- */ 1029 { 1066 1030 Palette_18ColorsBW(palette); 1067 1031 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 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); 1036 palette[i].reserved = (uint8) 0; 1037 } 1038 } 1039 1040 1041 /* -------------------------------------- */ 1042 void Palette_18ColorsGray(RGBQuad * palette) 1043 /* -------------------------------------- */ 1044 { 1081 1045 Palette_18Colors(palette); 1082 1046 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; 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); 1051 palette[i].reserved = (uint8) 0; 1052 } 1053 } 1054 1055 1056 /* --------------------------------- */ 1057 void Palette_2Colors(RGBQuad * palette) 1058 /* --------------------------------- */ 1059 { 1060 int level; 1121 1061 1122 1062 RGBQuad pattern[2]; … … 1132 1072 pattern[1].blue = level; 1133 1073 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; 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; 1078 palette[i].reserved = (uint8) 0; 1079 } 1080 } 1081 1082 1083 /* --------------------------------- */ 1084 void Palette_4Colors(RGBQuad * palette) 1085 /* --------------------------------- */ 1086 { 1087 int level; 1146 1088 1147 1089 RGBQuad pattern[4]; 1148 1090 1149 for (i=0; i<2; i++) {1150 level = (i <<8) - 1;1091 for (int i = 0; i < 2; i++) { 1092 level = (i << 8) - 1; 1151 1093 pattern[i].red = level; 1152 1094 pattern[0].green = level; … … 1154 1096 } 1155 1097 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; 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; 1102 palette[i].reserved = (uint8) 0; 1103 } 1104 } 1105 1106 1107 /* ---------------------------------- */ 1108 void Palette_16Colors(RGBQuad * palette) 1109 /* ---------------------------------- */ 1110 { 1111 int level; 1168 1112 1169 1113 RGBQuad pattern[16]; 1170 1114 1171 for (i=0; i<4; i++) {1172 level = (i <<8) - 1;1115 for (int i = 0; i < 4; i++) { 1116 level = (i << 8) - 1; 1173 1117 pattern[i].red = level; 1174 1118 pattern[0].green = level; … … 1176 1120 } 1177 1121 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 } 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; 1126 palette[i].reserved = (uint8) 0; 1127 } 1128 } 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
Note: See TracChangeset
for help on using the changeset viewer.