home *** CD-ROM | disk | FTP | other *** search
/ GRIPS 2: Government Rast…rocessing Software & Data / GRIPS_2.cdr / dos / seq / src / palbuild.c < prev    next >
C/C++ Source or Header  |  1990-01-07  |  1KB  |  55 lines

  1. /*     paload
  2. *
  3. *   Program to create a color palette that can be used by program PALOAD
  4. *   to load into the hardware lookup table.  Input file required for this
  5. *   program are lines in the form :
  6. *    entry_No red green blue
  7. *
  8. *   Lam Chih Chao    Oct, 1987
  9. *   National Centre for Supercomputing Applications
  10. *   University of Illinois
  11. *   This program is in the public domain
  12. */
  13. #include "stdio.h"
  14. #include <sys/file.h>
  15.  
  16. char rmap[256],bmap[256],gmap[256];
  17.  
  18. FILE *fp;
  19.  
  20. main(argc,argv)
  21.     int argc;
  22.     char *argv[];
  23.     {
  24.     register i;
  25.         int red,green,blue,entryNo;
  26.  
  27.  
  28.     if (argc < 2) {
  29.         printf("\n Usage: %s file \n",argv[0]);
  30.         exit(1);
  31.     }
  32.  
  33.     if (NULL == (fp = fopen(argv[1],"w"))) {
  34.     puts("Error on palette file open ");
  35.     exit(2);
  36.     }
  37.     
  38.     while (scanf("%d %d %d %d",&entryNo,&red,&green,&blue) == 4) {
  39.         printf ("red %d Green %d Blue %d\n", red, green, blue);
  40.     rmap[entryNo] = red;
  41.     gmap[entryNo] = green;
  42.     bmap[entryNo] = blue;
  43.     }
  44.  
  45.     fwrite(rmap,1,256,fp);
  46.     fwrite(gmap,1,256,fp);
  47.     fwrite(bmap,1,256,fp);
  48.  
  49.     
  50.    fclose(fp);
  51.  
  52.  
  53. }
  54.  
  55.